rails `bundle install` trying to install system wide - ruby-on-rails

I accidentally ran sudo bundle install and now when I run just bundle install I get an error:
Error details:
Errno::EACCES: Permission denied # rb_sysopen -
here are the environment/bundler settings:
Environment
Bundler 1.12.3
Rubygems 2.6.4
Ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
GEM_HOME /Users/abdulahmad/.rvm/gems/ruby-2.3.0
GEM_PATH /Users/abdulahmad/.rvm/gems/ruby-2.3.0:/Users/abdulahmad/.rvm/gems/ruby-2.3.0#global
RVM 1.27.0 (latest)
Git 2.5.4 (Apple Git-61)
rubygems-bundler (1.4.4)
Bundler settings
orig_path
Set via BUNDLE_ORIG_PATH: "/Users/abdulahmad/.rvm/gems/ruby-2.3.0/bin:/Users/abdulahmad/.rvm/gems/ruby-2.3.0#global/bin:/Users/abdulahmad/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/abdulahmad/.rvm/bin"
orig_gem_path
Set via BUNDLE_ORIG_GEM_PATH: "/Users/abdulahmad/.rvm/gems/ruby-2.3.0:/Users/abdulahmad/.rvm/gems/ruby-2.3.0#global"
is it trying to install system gems rather than just for my rails app? how can I fix this?

Update the global rubygems with :
sudo gem update --system --no-user-install.
Or try this:
bundle install --path ~/.gem
Other option is just uninstall bundler and install it again.

Related

Rails and Ruby versions always conflict, and will never be able to bundle install

I git cloned my own repo, when I want to start (rails s), there will be a request to install Rails (sudo apt install ruby-railties), even though I installed it. If I start the installation (gem install rails), there will be a message that the Ruby version is too old:
ERROR: Error installing rails:
There are no versions of activesupport (= 7.0.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
activesupport requires Ruby version >= 2.7.0. The current ruby ​​version is 2.6.6.146.
If I switch to the requested version (rvm use 2.7), the following message will appear when I run rails s:
Could not find proper version of railties (6.1.4.1) in any of the sources
Run `bundle install` to install missing gems.
When I proceed to bundle install, there will be a need to switch the Ruby version:
Your Ruby version is 2.7.2, but your Gemfile specified 2.6.6
This is equivalent to going back to the beginning. This stupid loop prevented me from completing the bundle install and thus rails s.
Regarding the pg error, you need to change your 'pg' gem to a lower version. Let us see what you have in your gemfile.
Setup the environment inside your project folder.
cd yourproject
Then install Ruby, Rails and Bundler.
Install Ruby v2.7.0, through Ruby Version Manager (RVM)
https://rvm.io/
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install ruby 2.7.0
rvm use 2.7.0
rvm list
Install Rails, through RubyGems https://rubygems.org
(don't use apt install ruby-railties )
gem install rails
rails --version
(re)Install Bundler
gem install bundler
bundle install

Can't bundle install after cloning repo

Here's my error when I bundle. What's the problem?
bundle install
rbenv: bundle: command not found
The `bundle' command exists in these Ruby versions:
2.3.1
command -v ruby
/home/brian/.rbenv/shims/ruby
command -v bundle
/home/brian/.rbenv/shims/bundle
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
bundle -v
Bundler version 1.15.3
Try:
Set correct ruby (rbenv) version rbenv global 2.3.1
And then rbenv rehash and then bundle install.
If that won't work I think you should reinstall bundler
Once again set correct ruby version rbenv global 2.3.1
gem uninstall bundler
gem install bundler
And then rbenv rehash and then bundle install.

Solidus gem showing error regarding ruby version during bundle install

I am trying to install Solidus gem which is a fork of spree and while running bundle install this shows up
Installing solidus_core 1.1.0
Gem::InstallError: solidus_core requires Ruby version >= 2.1.0.
An error occurred while installing solidus_core (1.1.0), and Bundler cannot
continue.
even when I am running ruby version 2.2.3
ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
I am using rbenv on OS X El Capitan to control the ruby versions. Is there a problem with ruby version control or any other issue?
Try to set ruby '2.2.3' in Gemfile, and execute bundle install.
If it's not resolved, please check your bundle path to execute this:
$ which bundle
/usr/bin/bundle # global
$ gem install bundler
$ bundle install --path vendor/bundle

OS X Mavericks broke rbenv?

Recently, I installed OS X Mavericks, and it seemed to have messed up my development environment. I got this message after running 'rails new first_app':
Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Password:
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.9.0)
Using atomic (1.1.15)
Using thread_safe (0.2.0)
Errno::EACCES: Permission denied - /Library/Ruby/Gems/2.0.0/build_info/tzinfo-0.3.39.info
An error occurred while installing tzinfo (0.3.39), and Bundler cannot continue.
Make sure that `gem install tzinfo -v '0.3.39'` succeeds before bundling.
I then did what was asked of me:
christohersmbp2:hartl christopherspears$ gem install tzinfo -v '0.3.39'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
What is weird is that I do have rbenv installed. In fact, while trying to debug this issue, I upgraded rbenv:
christohersmbp2:~ christopherspears$ brew update
Already up-to-date.
christohersmbp2:~ christopherspears$ brew upgrade rbenv ruby-build
Warning: A newer Command Line Tools release is available
Update them from Software Update in the App Store.
Error: rbenv-0.4.0 already installed
Error: ruby-build-20140225 already installed
However, I get this error message when I try to call rbenv from the command line:
christohersmbp2:hartl christopherspears$ rbenv
-bash: rbenv: command not found
christohersmbp2:~ christopherspears$ rbenv rehash
-bash: rbenv: command not found
I think I have the path set up properly:
christohersmbp2:hartl christopherspears$ echo $PATH
/usr/local/share/python:/Users/christopherspears/.rbenv/bin:/Users/christopherspears/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
This is what I have in my .bash_profile file:
# rbenv stuff
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Strangely enough, I do think I am using the Ruby version in my versions folder:
christohersmbp2:versions christopherspears$ pwd
/Users/christopherspears/.rbenv/versions
christohersmbp2:versions christopherspears$ ls
2.0.0-p247/
christohersmbp2:versions christopherspears$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Any hints? I seem to be doing everything correctly.
UPDATE:
I downloaded and installed the Xcode command line tools. Didn't seem to work:
christohersmbp2:~ christopherspears$ rbenv
-bash: rbenv: command not found
As #Christoper Spears say, uninstall then reinstall, or more specifically:
$ brew uninstall rbenv
$ brew install rbenv
(supposing you used brew to install it in the first place).
Well...the secret apparently is to uninstall and then reinstall rbenv. Actually, uninstalling and reinstalling a dev tool broken by OS X Mavericks seems to (almost) always be the solution.

RubyGems Installation - getting ruby: No such file or directory -- setup.rb (LoadError)

I run
gem install rubygems-update
but I get the following error:
ERROR: While executing gem ... (Gem::RemoteSourceException)
HTTP Response 302 fetching http://gems.rubyforge.org/yaml
My environemnt is:
~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.1.0 (1.1.0)
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
...
When I run:
$ ruby setup.rb
I get:
ruby: No such file or directory -- setup.rb (LoadError)
Please help.
First you need to successfully Installed Ruby. execute below command on console
ruby -v
If you get version of ruby then go ahead and download rubygems and extract the folder.
Suppose you download rubygems-1.8.17.tgz and extracted in /home/amit/rubygems1.8.17
cd /home/amit/rubygems1.8.17
ruby setup.rb
after successfully installed, do gem -v it should display gem version
If your RubyGems version is 0.8.5 or later, you can upgrade to the latest version with:
sudo gem update --system
If your current version of RubyGems is older than version 0.8.5, or specifically RubyGems 1.2.0, or you see the message “Nothing to update” when you tried gem update —system, then use the following commands:
gem install rubygems-update
update_rubygems
if your system requires root access to install ruby libraries, use sudo
Try updating your rubygems:
gem install rubygems-update --source http://production.s3.rubygems.org/
update_rubygems
If that doesn't work, this post:
Can't update RubyGems may help.
Check do you have setup.rb file or not. If you do have one then try to go into that where your file is located and the execute
ruby setup.rb

Resources