Problem running bundle install in MacOS terminal - ruby-on-rails

When running bundle install, I get the error
There was an error while trying to write to
'/Users/my-user/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions'.
It is likely that you need to grant write permissions for that path.
I am on Ruby version 2.3.3 using platform x86_64-darwin18.
Are they any suggestions on how to fix this error?
I have already tried unlocking the file, but it says that the file cannot be unlocked and only provides me with the opportunity to make a duplicate copy.

Can you try,
1) chown -R USERNAME /Users/my-user/.bundle/cache/compact_index/
2) sudo bundle install
3) bundle exec bundle install
4) Just give the permission to chown -R USERNAME /Users/my-user/.bundle/cache/
5) rm -rf /Users/my-user/.bundle/cache
Replace the USERNAME with your system username

Related

How do I remove Permission denied # rb_sysopen - Gem install error?

I am trying to install create a new app in Ruby on Rails and I cannot get passed this error:
$ gem install pg
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/pg-0.21.0/.gemtest
Its a permissions issue. You could fix it with this:
sudo chown -R $(whoami) /Library/Ruby/Gems/*
or possibly in your case
sudo chown -R $(whoami) /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/*
What does this do:
This is telling the system to change the files to change the ownership to the current user. Something must have gotten messed up when something got installed. Usually this is because there are multiple accounts or users are using sudo to install when they should not always have to.
It's likely there's a permissions problem somewhere along the .rbenv path. You might try turning on write privileges for your user with:
$ chmod -R +w ~/.rbenv
That will recursively (-R) change the file mode (chmod) to write permission (+w) for all files and directories under your user's .rbenv path. There's no particular reason for not having files set to write.
For Mac M1 systems try,
Allowing full disk access to terminal.
Apple->systemPreferences->Security&Privacy->privacy(Tab)->'+' button, check in Terminal application.
Then Restart terminal
2.Try using,
sudo chflags noschg
Delete the pod folder, reinstall it again. If it doesn't work use this command:
sudo pod install --allow-root
It really doesn't matter on mac how you configure your eyaml create the dir and config manually, add some public key location to it, and its works just fine after adding full disk access to the terminal as Kewin suggested ^ ^. Thumbs up.
No need to change permission, just export GEM_HOME:
export GEM_HOME="$HOME/.gem"
please run:
sudo gem install pg

how to pass the password in the script

I am writing a script where I am updating the ruby gems by bundle update command but it is asking the password with message Enter your password to install the bundled RubyGems to your system:
I have to pass the password silently without knowing user or in other ways i have to make it as automated.
currently I have do this with system command as system 'bundle update'
How can I do this.
Thanks.
Due to the way you installed ruby, you need sudo privileges in order to run bundle update.
If you would like to run the bundle command without sudo privileges, you need to chown the gem folders.
You can do this by cd-ing into the path of your gems, and then sudo chown -R username:groupname

I can't install gems with rvm

I'm new to ruby version manager and when i tried to install rails after installing it, I get this error . I tried to search other SO questions as well but didn't want to re-install ruby version manager. Even though when I try sudo for installation, it doesn't work.
The error I get is as follows:"ERROR: While executing gem ... (Errno::EACCES)Permission denied # dir_s_mkdir - /home/sunil/.gem/specs"
I would do this:
ls -ld /home/sunil/.gem/specs to check that folder permissions.
whoami to compare current user with /home/sunil/.gem/specs permissions
Maybe chown -R sunil:sunil ~/.gem to change owner in case .gem directory is not owned by sunil.
Maybe chmod -R u+rwX,go+rX,go-w ~/.gem to change permissions.

Permission denied. Rails could not complete the installation

I tried to install Ruby on Rails in my user account. Atraves user terminal, do the following.
I find that the minimum requirements are met
I write the command line to install Rails (poor man).
I get the following error message at the beginning of the installation process:
Searching for binary rubies, this might take some time.
Checking requirements for debian.
Installing requirements for debian
user password required for /usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:usr/local /games:/usr/games:/home/user/.rvm/bin:/sbin:/usr/sbin:/usr/local/sbin apt-get --quiet --yes update:
Updating system.
Error running requirements_debian_update_system ruby-2.0.0-p247, please read /home/user.rvm/log/1380100570_ruby-2.0.0-p247/update_system.log
Requirements installation failed with status: 1.
Maybe your problem is related with sudoers file.
try edit this file:
vim /etc/sudoers
in this file should be your user name with permissions. For example:
your_user_name ALL=(ALL) ALL
try to add if it don't exists:)
I solved the problem by reinstalling ruby separately with the version I wanted to use.
Then install rails via gem install rails-v
then clear the gem that made ​​reference to the error and rerun bundle install . Then select the version I wanted to use installing ruby rvm rvm use default -v

Permissions error with gem install

I had a very weird problem yesterday, where in the middle of trying to figure out some heroku problems, my whole Rails environment just disappeared. Bundle, RVM, rails, etc were no longer recognized. So I just ignored the possible cause and reinstalled everything. Mostly worked, but now I'm running into permissions problems. If I bundle install, it needs me to input my computer password for permission.
And I just ran into the following problem trying to "gem install heroku" in a new directory I wanted to deploy.
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Any idea how I get those permissions back so things run smoothly again?
Thanks!
Use chmod on the directory something like this:
sudo chmod -R g+w /Library/Ruby/Gems/1.8
That might work.

Resources