Gemset error when updating to Ruby 2.4.2 - ruby-on-rails

I'm updating from Ruby 2.0 to 2.4.2 using RVM, and receive the following error messages during an install using $ rvm install ruby-2.4.2:
Making gemset ruby-2.4.2 pristine - please wait
'command gem pristine --extensions bigdecimal --version 1.3.0 gem-wrappers --version 1.3.2 io-console --version 0.4.6 json --version 2.0.4 openssl --version 2.0.5 psych --version 2.2.2' failed, you need to fix this gems manually.
Error running '__rvm_with ruby-2.4.2 gemset_pristine',
please read /Users/myname/.rvm/log/1507820191_ruby-2.4.2/gemset.pristine-ruby-2.4.2.log
Making gemset ruby-2.4.2#global pristine - please wait
'command gem pristine --extensions bigdecimal --version 1.3.0 io-console --version 0.4.6 json --version 2.0.4 openssl --version 2.0.5 psych --version 2.2.2' failed, you need to fix this gems manually.
Error running '__rvm_with ruby-2.4.2#global gemset_pristine',
please read /Users/myname/.rvm/log/1507820191_ruby-2.4.2/gemset.pristine-ruby-2.4.2#global.log
I'm… not quite sure what this means, or what I should do next. Any thoughts? I'm running macOS 10.12.6.
[Edit]: Here's a copy of the error log.

According to the RVM docs, you don't use ruby- in the command.
It should be:
$ rvm install 2.4.2
I'm not sure if that matters or not though.
Have you tried upgrading RVM and Homebrew?
[Edit] Based on this info from the log file:
bigdecimal-1.3.0 +gemset_pristine:20> gem pristine --extensions bigdecimal --version 1.3.0
ERROR: Loading command: pristine (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
+gemset_pristine:21> _failed+=( 'bigdecimal --version 1.3.0' )
Looks like a zlib problem. Try installing (or re-installing) Command Line Tools.
$ xcode-select --install
There is a very similar issue on github https://github.com/rvm/rvm/issues/4090
It was solved by running $ brew doctor

Just came up against this after needing to use SASS after a while. During which time I had upgraded to El Capitan. So Ruby was 'Old'.
You could probably cut a lot of my steps out by running the following (with a little prior knowledge of the latest Ruby Version).
xcode-select --install
brew install zlib
rvm reinstall ruby-<latest_version> --with-zlib-dir=/usr/local/Cellar/zlib/<latest_version>
This was how I had to go about it. I didn't need to uninstall in the end but I took a lot of wrong turns.
Initially I had to run this line to get xcode up to date:
xcode-select --install
Then install zlib
brew install zlib
Take a note of the directory zlib is installed in
/usr/local/Cellar/zlib/1.2.11
Next update rvm
\curl -sSL https://get.rvm.io | bash -s stable --ruby
Following these steps got me to the point where I was running the latest version of ruby 2.4.1. But zlib wasn't linked to ruby.
So the final step was to run a reinstall
rvm reinstall ruby-2.4.1 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11

Found a fix as referenced in this RVM GitHub issue that involves installing zlib using brew and then re-installing ruby while pointing to that zlib directory.
As someone in that thread pointed out, this shouldn't be necessary. Still not sure why the problem arose.
Steps
$ brew install zlib
$ rvm remove 2.4.2
$ rvm install 2.4.2 —-with-zlib-dir=/usr/local/Cellar/zlib/1.2.11

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

Cannot use specific version of bundler

I'm on Debian 9 and I'm trying to use the 1.16.3 version of bundler on a ruby on rails site. However for some reason the system insists on using the older version 1.13.6 both by default and when I explicitly specify it:
To resolve this I tried completely uninstalling the 1.13.6 version:
Now I'm starting to feel like I'm taking crazy pills. Is it physically possible to use the 1.16.3 version?
Edit in reply to matthewd: which -a bundler finds two hits:
/usr/local/bin/bundler
/usr/bin/bundler
If run with bundler -v both report to be version 1.13.6
Edit in reply to Kedarnag Mukanahallipatna: There is no .rvm directory in /home/manos/. Could this be somewhere else?
Bundler is pain in the a**
You can solve this by executing these set of commands. Keep in consideration your ruby version also.
before_install:
- rvm implode --force
- \curl -sSL https://get.rvm.io | bash -s 1.27.0
- rvm reload
- rvm install 2.2.3
- gem uninstall -i /home/travis/.rvm/gems/ruby-2.2.3 bundler -x
- gem install bundler -v 1.16.3
After a lot of back and forth I ended up uninstalling ruby and rails that were previously installed via apt. I then reinstalled ruby via apt and instead of getting rails via apt I got it with
gem install rails
Bundler is now at 1.16.3.
A disclaimer though... since this whole thing has been a side issue while I was dealing with other rails problems, I've also done a bunch of other reinstalling so there's a chance something there affected the bundler. So there's that.

El Capitan Update rails

Just updated my system to El Capitan and when launching the rails server (that worked perfectly on Yosemite) I get the following warning.
Ignoring bcrypt-3.1.10 because its extensions are not built. Try: gem pristine bcrypt --version 3.1.10
Ignoring bcrypt-ruby-3.1.2 because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.1.2
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring binding_of_caller-0.7.2 because its extensions are not built. Try: gem pristine binding_of_caller --version 0.7.2
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
when running the referenced commands I get:
-bash: bundle: command not found
rails update
Ignoring json-1.8.1 because its extensions are not built. Try: gem pristine json --version 1.8.1
Ignoring json-1.8.2 because its extensions are not built. Try: gem pristine json --version 1.8.2
Ignoring json-1.8.3 because its extensions are not built. Try: gem pristine json --version 1.8.3
Ignoring nokogiri-1.6.6.2 because its extensions are not built. Try: gem pristine nokogiri --version 1.6.6.2
Ignoring atomic-1.1.14 because its extensions are not built. Try: gem pristine atomic --version 1.1.14
Ignoring atomic-1.1.14 because its extensions are not built. Try: gem pristine atomic --version 1.1.14
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring binding_of_caller-0.7.2 because its extensions are not built. Try: gem pristine binding_of_caller --version 0.7.2
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
Could not find bcrypt-3.1.10 in any of the sources
Run `bundle install` to install missing gems.
also tried running:
sudo gem pristine --all
Restoring gems to pristine condition...
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0/gems/CFPropertyList-2.2.8/README
So now, it can't even find the bundle install path. Seems like the update has really messed it up.
When I run gem pristine --all I get the following:
Restored bcrypt-ruby-3.1.5
Skipped bigdecimal-1.2.0, it is a default gem
Building native extensions. This could take a while...
Restored binding_of_caller-0.7.2
Restored bootstrap-sass-3.3.5.1
Restored builder-3.2.2
Restored builder-3.1.4
Restored bundler-1.10.6
Restored bundler-1.9.6
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20151001-3494-1jca623.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
make: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin15/ruby/config.h', needed by `breakpoint.o'. Stop.
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/byebug-6.0.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/byebug-6.0.2/gem_make.out
Solution is in the following link.
Hardware
Upgrade to El Capitan, with Homebrew & Ruby
... and Xcode and Java, etc.
If you don't already have homebrew installed, do that first, so you don't have to deal with SIP issues. Install all Software Updates available in the Apple Menu, up to and including El Capitan.
After the installs and forced reboots my 27" Thunderbolt display wouldn't display anything. Unplug, replug didn't help. One more reboot fixed it.
Software
In order...
Xcode
The El Capitan install wiped out my Xcode install, so I had to search for it in the App Store and reinstall. I now believe that I deleted Xcode awhile ago and forgot, hence the reinstall. I did this on a machine that I rarely use.
After Xcode is finished installing, open iTerm, which I use as a Terminal.app replacement, or Terminal.app if you are so inclined.
∴ xcode-select --install
xcode-select: note: install requested for command line developer tools
A dialog opened, I chose "Install", which finished in about a minute.
Java
Next, run java, which prompts with a dialog that has a button "More Info" which takes you to a website where you can accept the license and download the Java .dmg file. You need the JDK, not the JRE, if you intend to run java command-line based tools.
Unable to find any JVMs matching version "1.7".
No Java runtime present, try --request to install.
∴ java
No Java runtime present, requesting install.
Once downloaded, open the .dmg (for me it was jdk-8u60-macosx-x64.dmg) and install, then restart iTerm.
∴ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Apps like RubyMine should work now, well, at least launch.
Homebrew
The doctor informed me of several warnings which I took care of as instructed.
∴ brew doctor
∴ sudo chown -R $(whoami):admin /usr/local
∴ cd /usr/local/Library && git stash && git clean -d -f
∴ cd ~
∴ brew prune
∴ brew unlink qt5
Then I was able to update Homebrew.
∴ brew update
qt5
I know the capybara-webkit gem will require qt5, and I know qt is one of the primary remaining pain points in homebrew / El Capitan issues tracker, so I decided to get it out of the way first.
∴ brew uninstall qt5
∴ brew install qt5
∴ brew linkapps qt5
∴ brew link --force qt5
That last line is required to make qmake available. Check with which qmake. Otherwise you will end up with this on the Capybara install later on:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/pboling/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150930-48087-1vw6bye.rb extconf.rb
sh: qmake: command not found
*** extconf.rb failed ***
GPG
Some software is now being signed with GPG, like RVM, for example, so install it.
∴ brew install gpg
RVM
My Ruby was working, but I was having trouble with some native gem installations, so I decided to start fresh with a Ruby compiled against all the new homebrew and Xcode libraries.
∴ rvm implode
Implode actually failed to remove the main ~/.rvm directory due to permissions issues. I had to sudo remove it.
∴ sudo rm -rf /Users/pboling/.rvm
Follow the instructions here for installing RVM, I installed the development version, hoping it would have more El Capitan fixes in it:
∴ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
∴ \curl -sSL https://get.rvm.io | bash
The main app I currently work on is using Ruby 2.1.2, so I install that first, and then go to the project directory to have the gemset created and to bundle.
∴ rvm install 2.1.2
∴ cd ~/project
∴ gem install bundler -v 1.9.7
∴ bundle install
Bundler version 1.9.7 because that's what Heroku is on, and I want to stay in sync, because 1.10* changed things that make the Gemfile.lock incompatible with 1.9.7 on the deployed server (for me, with multiple gem sources, private gem server, etc).
Postgres
I also took the opportunity to upgrade to the latest Postgres.app. Alternatively you can install postgres with brew install postgres. I choose Postgres.app begause it is supported directly by Heroku, and I like to think there is a parity win there somewhere.
You should try RVM or RBENV or whatever the flavor of the week is. This will allow you to easily manage your Ruby Interpreters and Gemsets on a per project basis. I still use RVM and I'm quite happy with it.
https://rvm.io/rvm/install

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.

Why do I get a bcrypt-ruby gem install error?

Getting an error when trying to install the gem devise, the installation is stopping on
the gem bcrypt-ruby:
$ gem install bcrypt-ruby
Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
I'm running OSX 10.6.7 with Ruby under RVM.
I reinstalled the lastest version of xcode & reinstalled Ruby 64bit, Rails and all the gems.
I had the same problem installing under OSX 10.7.3. When installing the gem, my error message was:
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
creating Makefile
make
compiling bcrypt_ext.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [bcrypt_ext.o] Error 1
Looks like the gem is looking for gcc-4.2 but I only had a file called gcc. Now since I had just installed the latest Xcode (4.3), I knew that my C compiler was compliant but the gem had gcc-4.2 hardcoded into it. So my solution was:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
The linking worked like a charm.
Looks like there might be some info missing here - for me, this was due to a brew install of gcc. gcc was in /usr/bin, but not gcc-4.2. So I just did the following:
$ cd /usr/bin
$ sudo ln -s gcc gcc-4.2
which creates a link, gcc-4.2, which the gem is looking for that goes back to gcc.
Hope that helps.
It requires to install ruby-dev before installing bcrypt-ruby.
If you are using Ubuntu, run
sudo apt-get install ruby1.9.1-dev
or
sudo apt-get install ruby1.8-dev
based on RUby version.
I'm using RVM & I kept having this issue whenever installing gems with native extensions (bcrypt-ruby, bson-ext, json, eventmachine, nokogiri, linecache19, etc.)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
Only way I could finally get things working was to uninstall then re-install ruby.
rvm remove 1.9.2
rvm install 1.9.2
Thanks to tip from #doublebee here:
https://github.com/flori/json/issues/78#issuecomment-1499920
You only need use rvm (ruby version manager)
rvm uninstall 1.9.3
and then
rvm install 1.9.3
looks this error is on build of rvm 1.9.3, but uninstall and reinstalling fix the problem with bcrypt-ruby 3.0.1
sudo apt-get install ruby1.9.1-dev
whoked charm for me! Thanks a lot
Well, it works with Ruby 1.9.2 under RVM on MacOS 10.6.7:
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
$ gem install bcrypt-ruby
Fetching: bcrypt-ruby-2.1.4.gem (100%)
Building native extensions. This could take a while...
Successfully installed bcrypt-ruby-2.1.4
1 gem installed
Installing ri documentation for bcrypt-ruby-2.1.4...
Installing RDoc documentation for bcrypt-ruby-2.1.4...
Try rvm notes and see if it says you need to install anything.
If you are using version 1.8 the required packages for bcrypt are in the dev bundle. Try using
$sudo apt-get install ruby1.8-dev
then
$gem install bcrypt-ruby
This fix work for me on ubuntu on osx use homebrew, macports whatever:
sudo apt-get install ruby1.9.1-dev
I think you need to reinstall bundler gem.
gem install bundler
and then
bundle install

Resources