1

All of a sudden I'm no longer able to run the bundle command in my project. I'm using Ubuntu for development and was following a tutorial on how to deploy to Azure.

When I cd to my project directory and runn bundle I get the following message:-

Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/usr/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /var/lib/gems/2.1.0/extensions/x86-linux/2.1.0/kgio-2.9.2 (Errno::EACCES)
    from /usr/lib/ruby/2.1.0/fileutils.rb:250:in `fu_mkdir'
    from /usr/lib/ruby/2.1.0/fileutils.rb:224:in `block (2 levels) in mkdir_p'
    from /usr/lib/ruby/2.1.0/fileutils.rb:222:in `reverse_each'
    from /usr/lib/ruby/2.1.0/fileutils.rb:222:in `block in mkdir_p'
    from /usr/lib/ruby/2.1.0/fileutils.rb:208:in `each'
    from /usr/lib/ruby/2.1.0/fileutils.rb:208:in `mkdir_p'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:210:in `write_gem_make_out'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:132:in `build_error'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:171:in `rescue in build_extension'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:156:in `build_extension'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
    from /usr/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
    from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
    from /usr/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
    from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
    from /usr/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
    from /usr/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
    from /usr/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
    from /usr/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
    from /usr/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
    from /usr/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
    from /usr/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /usr/lib/ruby/vendor_ruby/net/http/persistent.rb:12:in `<top (required)>'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler/vendored_persistent.rb:7:in `<top (required)>'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler/fetcher.rb:1:in `<top (required)>'
    from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:239:in `install'
    from /usr/lib/ruby/vendor_ruby/thor/command.rb:27:in `run'
    from /usr/lib/ruby/vendor_ruby/thor/invocation.rb:121:in `invoke_command'
    from /usr/lib/ruby/vendor_ruby/thor.rb:363:in `dispatch'
    from /usr/lib/ruby/vendor_ruby/thor/base.rb:440:in `start'
    from /usr/bin/bundle:20:in `block in <main>'
    from /usr/lib/ruby/vendor_ruby/bundler/friendly_errors.rb:3:in `with_friendly_errors'
    from /usr/bin/bundle:20:in `<main>'

I'm in way over my head. Has anyone any idea what I've done to break it or how I can fix it

4
  • Looks like you have a permissions problem at /var/lib/gems/2.1.0/extensions/x86-linux/2.1.0/kgio-2.9.2 Do you have all the rights to write to that directory? Commented Nov 10, 2014 at 22:28
  • Its a virual machine running on virtualbox so I should have all the rights? I'll try and create a file there Commented Nov 10, 2014 at 22:36
  • Just looked and there's no file or directory called kgio-2.9.2 in that directory? Commented Nov 10, 2014 at 22:39
  • All that's there is bcrypt-3.1.9 and pg-0.17.1 Commented Nov 10, 2014 at 22:39

2 Answers 2

2

As you can see from the stack trace,

/usr/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': 
  Permission denied @ dir_s_mkdir - 
  /var/lib/gems/2.1.0/extensions/x86-linux/2.1.0/kgio-2.9.2 (Errno::EACCES)
    ...
    from /usr/lib/ruby/2.1.0/fileutils.rb:208:in `mkdir_p'
    ...

bundler is trying to create the directory: /var/lib/gems/2.1.0/extensions/x86-linux/2.1.0/kgio-2.9.2. It is using the equivalent of mkdir -p, which will "create intermediate directories as required." (see man mkdir). So, you need permission to create that directory.

If you're not familiar with unix permissions, you'll have to do some reading, e.g. https://en.wikipedia.org/wiki/File_system_permissions#Traditional_Unix_permissions

Some tools that will be useful include cd, ls -l, chown, and chmod. Don't use them until you've read their manuals, especially chown and chmod.

Sign up to request clarification or add additional context in comments.

3 Comments

I'll start reading the docs now. Is there any reason why bundler can't write to that particular directory? I've just tried to create one there in terminal but it said 'mkdir: cannot create directory ‘alzer’: Permission denied'. Then I used sudo and was able to create one
I'm a bit slow tonight. Just had to run sudo bundle install and it installed the necessary gems. I was about to start chown(ing) directories. Thank god I copped on. Who knows what I would have done. Thanks for your help
Just be aware that when you use sudo the files you create are owned by root. sudo stands for "super-user do". root is the super-user. It's commonly held to be a mistake to install gems as root, but in the case of a VM maybe it's reasonable? I don't know.
1

just remove .bundle directory in your application path

1 Comment

Thanks. I moved to an Ubuntu dual boot on my laptop so all is sorted

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.