Gemfile.lock write error, permissions?
Your app root directory (whose permissions govern file creation) and files are all owned by root instead of your user (possibly because you did sudo rails new
—don’t use sudo
for that). You can change the permissions by doing:
sudo chown -R $(whoami):$(whoami) myappfolder
Where “myappfolder” is your Rails app’s root directory.
By the way, a good tip with regard to sudo
is to always try the command without it first, then, if there’s a permissions error when it runs, you may need sudo
. Don’t default to using sudo
.
Updating Gemfile.lock fails
Turned out that setting write permissions on cache
directory (/usr/lib/ruby/gems/2.4.0/cache/
) is not enough. You have to set write permissions for the parent directory (/usr/lib/ruby/gems/2.4.0/
). For some reason, bundle update
doesn't write to cache
unless you do that even though it doesn't write anything to any other directories on the same level as cache
.
Installing bundler gives me you don't have write permissions error
The problem was fixed by switching to the ruby version 2.3.0 by running the command rvm user 2.3.0. Once that is done you should restart the workspace. The reason for the error was the fact that when you switch ruby version it also changes gem files. Therefore, it wasn't able to recognize the gems.
Not able to include 'git' gem in ruby Gemfile
It looks like you manually crafted the Gemfile.lock
file. This is usually never needed, as that file is generated by bundle
automatically. It essentially contains the exact version numbers that bundler has downloaded for you.
Bundle, when running in deployment mode (--deployment
) will check both of your files, and will refuse to run, if there are any mismatches between them, or if the Gemfile.lock file would need any updates. This is done as a sanity check, as those files should be made in sync while development, and not during production.
Try to remove Gemfile.lock
, and start over. Since the version numbers you need to use are already present inside your Gemfile
, it should make a proper Gemfile.lock
without any issues. Also at first do not run it in --deployment
mode, as that one will not generate a Gemfile.lock
file.
All of these steps are actually noted in the error message you re receiving from bundler:
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
Note that the Gemfile.lock
file that is generated afterwards is still important (it contains the exact versions you are using), and should be part of your repository.
Also an additional problem you might encounter is that you are still using ruby 1.9, so you also have to fix the pg
gem version inside your Gemfile
like so:
source 'https://rubygems.org'
gem 'pg', '~> 0.18.4'
gem 'git', '~> 1.3'
the resulting Gemfile.lock
will be something like this:
GEM
remote: https://rubygems.org/
specs:
git (1.3.0)
pg (0.18.4)
PLATFORMS
ruby
DEPENDENCIES
git (~> 1.3)
pg (~> 0.18.4)
There was an error while trying to write to `/opt/wpscan/.bundle/config`. It is likely that you need to grant write permissions for that path
Fixed it bycurl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.2.3
rvm use 2.2.3 --default
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
gem install bundler
And sudo chmod -R 777 /opt/wpscan/.bundle
Works fine, thanks.
Grant permission for the path
It looks like you ran bundle install
as root at some point (via sudo bundle install
), which you should never do. You can sudo
it again to get past this problem, as @GurmukhSingh suggests, but that's just going to compound the problem and isn't a good idea from a security standpoint.
If you want to find files in your Bundler cache that aren't owned by fil
(assuming your username is fil
), you can run this:
find ~/.bundle/cache ! -user fil -ls
If that returns anything at all, then the problem is likely that those files are owned by root
(or some other user); the -ls
flag to find
will show you who owns them.
You can delete the offending files and run bundle install
again, or you can change the ownership of them with:
chown -R fil ~/.bundle/cache
You may need to check on all files in ~/.bundle
and not just the cache
dir.
In the future, don't run bundle install
via sudo
.
Related Topics
Error: Error Installing Ffi: Error: Failed to Build Gem Native Extension
Is the &Method(:Method_Name) Idiom Bad for Performance in Ruby
Ruby on Rails: Advanced Search
Is There a Hook Similar to Class#Inherited That's Triggered Only After a Ruby Class Definition
Ruby Differences Between += and << to Concatenate a String
How to Install Ruby-Debug When Needing Necessary Libraries And/Or Headers
Rails Devise: User_Signed_In? Not Working
How to Split a String to Get All the Substrings by Ruby
What Will Give Me Something Like Ruby Readline with a Default Value
Rails 2 to Rails 3:Using Link_To Instead of Link_To_Remote (Including Remote and Update)
Ruby Array Subtraction Without Removing Items More Than Once
Ruby on Windows Causes Error Cannot Load Such File Bcrypt_Ext
Character Encoding Issue in Rails V3/Ruby 1.9.2
Rails Catch-All/Globbing Routes
Convert Time from One Time Zone to Another in Rails
How to 'Bundle Install' When Your Gemfile Requires an Older Version of Bundler
Rails Installation Failed on Ubuntu With "Cannot Load Such File - Mkmf"