by mistake I ran sudo bundle install on my project and now when I run it as myself bundle install I am getting permission denied errors (below). I tried the instructions here https://github.com/bundler/bundler/blob/master/ISSUES.md#other-problems, also tried cloning my project into a fresh directory and running bundle from there, no use. Please help!
error: cannot open .git/FETCH_HEAD: Permission denied
Retrying git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b" due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b"` in directory /usr/local/lib/ruby/gems/2.1.0/bundler/gems/em-postgresql-adapter-3dfcc60378e9 has failed.
If this error persists you could try removing the cache directory '/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b'
error: cannot open .git/FETCH_HEAD: Permission denied
Retrying git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b" due to error (3/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b"` in directory /usr/local/lib/ruby/gems/2.1.0/bundler/gems/em-postgresql-adapter-3dfcc60378e9 has failed.
If this error persists you could try removing the cache directory '/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b'
error: cannot open .git/FETCH_HEAD: Permission denied
Git error: command `git fetch --force --quiet
--tags "/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b"` in directory
/usr/local/lib/ruby/gems/2.1.0/bundler/gems/em-postgresql-adapter-3dfcc60378e9
has failed.
If this error persists you could try removing the cache directory
'/home/akonsu/.bundler/cache/git/em-postgresql-adapter-361cdc05eba5661bb17040a7a6c2a093f9c2263b'
I had today the same issue today in my mac. I solved it by deleting the folder ~/.bundle .
After that I run bundle install --path ~/.bundle and everything was working fine again.
Cloning the repo to a new directory would not help. You installed the gems to the standard gems directory instead of a bundle specific directory.
The best option is to install the bundle to a new directory and ignore the gems installed in the system path.
Try bundle install --path /home/akonsu/.new_project_bundle. You do not have to specify this option every time. It is remembered.
http://bundler.io/v1.3/man/bundle-install.1.html
Also you need to set the permissions of the bundler's cache directory as mentioned in the comments (or delete it).
Read what's given on the bundler's website and no external help would be needed.
Gems will be installed to your default system location for gems. If your system gems are stored in a root-owned location (such as in Mac OSX), bundle will ask for your root password to install them there.
While installing gems, Bundler will check vendor/cache and then your system's gems. If a gem isn't cached or installed, Bundler will try to install it from the sources you have declared in your Gemfile.
The --system option is the default. Pass it to switch back after using the --path option as described below.
Install your dependencies, even gems that are already installed to your system gems, to a location other than your system's gem repository. In this case, install them to vendor/bundle.
$ bundle install --path vendor/bundle
Further bundle commands or calls to Bundler.setup or Bundler.require will remember this location.
Source: http://bundler.io/v1.9/bundle_install.html
I had the same issue today. I deleted the bundler directory from /Library/Ruby/Gems/2.3.0/ and then reinstalled bundler with sudo gem install bundler. Quite radical solution but solves the issue.
chmod 777 /usr/local/lib/ruby/gems/2.3.0/bundler/gems
Related
I am trying to use Cocoapods, but I'm stuck with even setting it up properly. It keeps showing me
-bash: pod: command not found
and I can't do anything. Also, the
$ pod init
doesn't work. I suppose the my computer cannot find any commands related to Cocoapods.
I've followed all the ways that was listed on the Cocoapods website, and read from websites such as raywenderlich but nothing helped.
$ sudo gem install cocoapods
Successfully installed cocoapods-1.7.5
Parsing documentation for cocoapods-1.7.5
Done installing documentation for cocoapods after 2 seconds
1 gem installed
$ pod setup --verbose
-bash: pod: command not found
I expect it to clone the CocoaPods Master Specs repository into ~/.cocoapods/ on my computer. Please help.
I actually thought you'd get the "You don't have write permissions for the /usr/bin directory." error, but your successfully installing it. I'm not sure why it's installing it in and then reading from another.
Try installing in a different directory:
sudo gem install -n /usr/local/bin cocoapods
For more see here
I want to install Cocoa Pods, with the command sudo gem install cocoapods, but terminal show this error:
YAML safe loading is not available. Please upgrade psych to a version
that supports safe loading (>= 2.0).
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/fuzzy_match
How can I resolve it? Thank a lot!
The problem is that you don't have permissions to run executables from /usr/bin, so you need to pass folder where to install cocoapods with proper permissions.
There are 2 ways:
Create new folder for GEM_HOME
mkdir -p $HOME/Software/ruby
export GEM_HOME=$HOME/Software/ruby
gem install cocoapods
When installation finished
export PATH=$PATH:$HOME/Software/ruby/bin
Install Cocoa Pods to /usr/local/bin
sudo gem install cocoapods -n /usr/local/bin
-n flag tells where binary files will be located.
With the latest version of bundler, I keep getting errors such as:
STDOUT: There was an error while trying to write to /home/user1/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47.
It is likely that you need to grant write permissions for that path.
I'm running sudo su - user2 bundle install synapse, where user2 has no HOME directory. I'm trying to install Airbnb Smartstack using Chef.
It seems that the latest version of Bundler insists on writing the new index cache files to $HOME/.bundle. This means that commands such as:
sudo su - homelessuser bundle install synapse
...fail when they try to write to the $HOME/.bundle of the user that called sudo ....
As a workaround, I'm pinning my bundler version to 1.11.2 for now.
Note The GitHub issue for this can be found here
I'm trying to setup gitlab and thus install some gems from another user account using sudo,
but I'm constantly getting Permission denied error.
sudo -u gitlab -H bundle install --deployment --without development test postgres
> Using ... ( a lot of successful gems there )
> Using pygments.rb (0.3.2) from https://github.com/gitlabhq/pygments.rb.git (at master)
> Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem
> An error occurred while installing pygments.rb (0.3.2), and Bundler cannot continue.
> Make sure that `gem install pygments.rb -v '0.3.2'` succeeds before bundling.\
sudo -u gitlab -H gem install pygments.rb -v '0.3.2'
> Successfully installed pygments.rb-0.3.2
> 1 gem installed
> Installing ri documentation for pygments.rb-0.3.2...
> Installing RDoc documentation for pygments.rb-0.3.2...
# no matter how many times I run this command, I always get the same output
# as if the gem installation doesn't stick
# I've tried to chmod
chmod 777 -R /usr/local/lib/ruby
# then Again
sudo -u gitlab -H bundle install --deployment --without development test postgres
# same result, Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem
Lain suggested to try to install the bundles into another sub directory. When that worked out, it became clear the problem was about permissions in the current directory.
Executing chown -R gitlab:gitlab . has solved the problem.
In the gitlab installation guide there is a gem install command preceding our story that was ran as root and probably the gemfile or some other file had permissions change during that.
This is a permissions bug in ruby-2.0.0-p195 rvm with bundle install
are you using rvm? did you try chmod with sudo?
chmod 755 (or 777) ~/.rvm/gems/ruby-2.0.0-p195/build_info/
I did the following and got things working.
I changed the permission for the Gemfile. i.e. chmod 755 Gemfile
Then I did a sudo bundle install. This got things working and all the gems got installed. I could then start my app by rails server
Make sure your Gemfile.lock is owned by the user running the command
Although Alex's answer is correct,this worked for me as well
sudo chown -R git:git /path/to/external/volume
I'm using Digital Ocean's Gitlab Image
I'm attempting to build my first ruby gem and all seemed to go well until I attempted to install the gem. I'm using RVM so no need for 'sudo gem install' here.
First I attempted to do the following:
jim:~/Desktop/spectest \ [git:master]
→ rake manifest
(in /Users/jim/Desktop/spectest)
Cleaning
- pkg
rm -rf pkg
Building Manifest
Manifest
README
Rakefile
bin/buildcss
...
jim:~/Desktop/spectest \ [git:master]
→ rake install
(in /Users/jim/Desktop/spectest)
Cleaning
Gemspec generated
mkdir -p pkg
mkdir -p pkg/css-reader-0.1.0
rm -f pkg/css-reader-0.1.0/Manifest
...
cd pkg
tar zcvf css-reader-0.1.0.tar.gz css-reader-0.1.0
a css-reader-0.1.0
a css-reader-0.1.0/bin
...
cd -
WARNING: description and summary are identical
Successfully built RubyGem
Name: css-reader
Version: 0.1.0
File: css-reader-0.1.0.gem
mv css-reader-0.1.0.gem pkg/css-reader-0.1.0.gem
Private key not found; gem will not be signed.
Targeting "ruby" platform.
Password:
Sorry, try again.
Password:
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d css-reader`
Successfully installed css-reader-0.1.0
1 gem installed
Installing ri documentation for css-reader-0.1.0...
Updating class cache with 3288 classes...
Installing RDoc documentation for css-reader-0.1.0...
Ok - so I wasn't certain why I got the Gem::InstallError here. Is there a log ruby gems keeps that I can find more details regarding the error? Either way I attempted to try installing the .gem package directly:
gem install pkg/css-reader-0.1.0.gem
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/jim/.rvm/gems/ruby-1.9.2-preview1/gems/css-reader-0.1.0/Manifest
And I get a bit more feedback. This time it looks like a permissions error with the Manifest file. So I attempted to chmod 777 the Manifest file and repeat the process all over again but I keep getting the error. Seems like a novice mistake somewhere on my behalf. Any advice is appreciated!
It is possible at some stage that you had something run with sudo which messed up your permisisons. Have you tried chown -R jim ~/.rvm
I solved the problem changing the ~/.gem permissions:
sudo chown user ~/.gem -R
right on. solved a similar problem. i had ~/.gem directory locked down for some reason while switching between sudo and such. Thanks!