I'm currently trying to use TravisCI properly for my rails app but I'm a bit stuck with the problem I'm facing.
In my .travis.yml
I've got this :
language: ruby
before_install:
- gem install bundler
rvm:
- 2.0.0
env:
- DB=sqlite
- DB=mysql
- DB=postgresql
script:
- rake db:migrate
- rake db:test:prepare
And in my Gemfile I precise Ruby version : ruby "2.0.0"
With this .travis.yml the tests fails saying to me :
$ gem --version
2.0.3
$ bundle install --deployment
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
But when I modify my .travis.yml like this :
language: ruby
before_install:
- gem install bundler
rvm:
- 1.9.3
- 2.0.0
env:
- DB=sqlite
- DB=mysql
- DB=postgresql
script:
- rake db:migrate
- rake db:test:prepare
Travis CI runs the test twice (once for 1.9.3 version and once for 2.0.0 version)
and fails with 1.9.3 version and succeed with 2.0.0 version.
What am I doing wrong in order to just pass the test with 2.0.0 ruby version ?
Cordially rob
I found what was wrong, TravisCI was looking for a .travis.yml in each branch but I only had one in my master branch (I thought TravisCI was only checking master branch).
I added a .travis.yml and all was ok.
I had a similar issue with the same error message even though my .travis.yml was included. The solution that worked for me was to include the generated Gemfile.lock in the repo as well.
Related
My ruby version is 2.3.0, my mysql version is 8.0.23, my mysql2 version is 0.5.3, my rails version is 5.0.7.2, and my Xcode version is 12.5.
I use macOS Big Sur(version 11.4) and the text editor "Atom".
I'm planning to release my Rails application with the URL of HEROKU(example. https://[My APP Name].herokuapp.com).
I ran the following command.
$ bundle exec rake secret
bash: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/
usr/bin/ruby: bad interpreter: No such file or directory
I installed the ruby version "2.3.0" as below ,because bundle seems to call "2.3".
$ rbenv install 2.3.0
Downloading openssl-1.0.2u.tar.gz...
-> https://****
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/****/.rbenv/versions/2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://****
Installing ruby-2.3.0...
WARNING: ruby-2.3.0 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
Installed ruby-2.3.0 to /Users/****/.rbenv/versions/2.3.0
I verified that the ruby version "2.3.0" is installed and the current ruby version is "2.3.0".
$ rbenv local 2.3.0
$ rbenv rehash
$ rbenv versions
system
* 2.3.0
$ rbenv global 2.3.0
$ rbenv rehash
$ rbenv versions
system
* 2.3.0
But the ruby current version is "2.6.3" when used the below command.
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [universal.x86_64-darwin20]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/****/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/****/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-20
- GEM PATHS:
- /Library/Ruby/Gems/2.6.0
- /Users/****/.gem/ruby/2.6.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/****/.rbenv/shims
I ran the following command.
$ bundle exec rake secret
bash: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/
usr/bin/ruby: bad interpreter: No such file or directory
Would you like to tell me how to get rid of /usr/local/bin/bundle?
Because my bundle exec should work if I can get rid of /usr/local/bin/bundle.
And should I reinstall the Xcode ,that is command line tools? The 1st answer of the below URL recommends to try running xcode-select --install to (re)install the Xcode command line tools.
Cannot install Jekyll after updating to Catalina - An error occurred while installing ffi (1.9.18)
Looks like your /usr/local/bin/bundle precedes the bundle executable from rbenv in your PATH.
Could it be that you installed ruby with some other tools than rbenv (additionally to rbenv installation)?
In my macOS setup i do not have a file /usr/local/bin/bundle
$ ls /usr/local/bin/bundle
ls: /usr/local/bin/bundle: No such file or directory
and the bundle executable is loaded from my rbenv installation:
$ which bundle
/Users/***/.rbenv/shims/bundle
I think, if you can get rid of /usr/local/bin/bundle your bundle exec could work.
(you could try this with renaming the /usr/local/bin/bundle temporary, if you do not know how this bundle file was installed on your system)
I am using GitLab-CI/CD to build my Rails application. I have noticed my builds are failing due to Using a custom path while using system gems is unsupported error, which were working perfectly fine before.
Tried to check newer update releases but didn't find any issues. Does any one have any idea on recent updates or somthing on mentioned issue?
Bellow is my gitlab-ci.yml
variables:
GIT_SUBMODULE_STRATEGY: recursive
cache:
key: ${CI_JOB_NAME}
paths:
- vendor/ruby
before_script:
- apt-get update -qq
- ruby -v
- which ruby
- gem --version
- git --version
- gem update --system 2.7.6
- gem install bundler -v 2.0.1
- bundle -v
- bundle config ${REPO_URL} ${BUNDLE_GITLAB__TOKEN}
- bundle config --global disable_shared_gems true
- bundle install --jobs $(nproc) "${FLAGS[#]}" --path vendor
rubocop:
tags:
- rubocop
script:
- bundle exec rubocop
# rspec:
# stage: test
# script:
# - bundle exec rspec
And bellow is the brief error I'm getting
$ apt-get update -qq
$ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
$ which ruby
/usr/local/bin/ruby
$ gem --version
3.0.3
$ git --version
git version 2.20.1
$ gem update --system 2.7.6
Updating rubygems-update
Successfully installed rubygems-update-2.7.6
Installing RubyGems 2.7.6
Bundler 1.16.1 installed
RubyGems 2.7.6 installed
Regenerating binstubs
------------------------------------------------------------------------------
RubyGems installed the following executables:
/usr/local/bin/gem
/usr/local/bin/bundle
RubyGems system software updated
$ gem install bundler -v 2.0.1
Successfully installed bundler-2.0.1
1 gem installed
$ bundle -v
Bundler version 2.0.1
$ bundle config https://gitlab.com/dharshannn/test-star.git ${BUNDLE_GITLAB__TOKEN}
$ bundle config --global disable_shared_gems true
$ bundle install --jobs $(nproc) "${FLAGS[#]}" --path vendor
Using a custom path while using system gems is unsupported.
path:
Set for your local app (/usr/local/bundle/config): "vendor"
path.system:
Set via BUNDLE_PATH__SYSTEM: true
disable_shared_gems:
Set for the current user (/root/.bundle/config): true
ERROR: Job failed: exit code 1
The same happened to me today. I am pretty sure that there was no update to bundler or gem. The Docker image however has been updated (I was using ruby:2.6.3). I also added a new dependency when this started happening, so I suspect it was dependent on a gem which was already installed in the system path thus the error message.
You can get around it by specifying the following configuration variables in your .gitlab-ci.yml:
variables:
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_PATH__SYSTEM: "false"
This will configure Bundler to not use shared gems and disable system gems fully.
See https://bundler.io/v2.0/bundle_config.html
disable_shared_gems (BUNDLE_DISABLE_SHARED_GEMS): Stop Bundler from accessing gems installed to RubyGems' normal location.
and
path.system (BUNDLE_PATH__SYSTEM): Whether Bundler will install gems into the default system path (Gem.dir).
Bundler can not find Rake.
How do I fix my Gem path so that my Ruby gems get installed in a place where Bundler can find it?
If I do:
gem env
I see:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2015-04-13 patchlevel 645) [universal.x86_64-darwin15]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-15
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/lkrubner/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-ri --no-rdoc"
- "update" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
And Rake is there:
ls -al /Library/Ruby/Gems/2.0.0/gems
rake-0.9.6
rake-10.4.2
rake-11.2.2
rdoc-4.0.0
test-unit-2.0.0.0
But none of this matters for the current project.
I am taking over a Rails project from another developer.
Rails 4.2
Rake 11..2.2
Ruby 2.0.0
If I look in
.bundler/config
I see:
BUNDLE_PATH: vendor/cache
BUNDLE_DISABLE_SHARED_GEMS: '1'
If I use "find" I can see that I've installed several versions of Rake:
vendor/cache/rake-11.2.2.gem
vendor/cache/ruby/2.1.0/gems/rake-10.5.0/
vendor/cache/ruby/2.1.0/gems/rake-11.2.2
vendor/cache/ruby/2.1.0/gems/rake-10.4.2
But most of these are going to a ruby 2.1 folder, instead of 2.0.
But if I try:
bundle exec rake db:setup
I get:
Could not find rake-11.2.2 in any of the sources
I've tried "bundle install".
I've tried deleting Gemfile.lock.
I've tried to avoid using "bundle exec".
I can't get anything to work.
I just need to get the system to use one path. The versions are not very important.
How do I get everything to agree on one path?
If I run "bundle install" then in the output I see "Using rake 11.2.2". So the "bundle" command sees rake when Bundler is doing the "install" task, but not when it is doing the "exec" task.
By the way:
which rake
/usr/local/bin/rake
This is hard-coded to the 2.0 version of Ruby:
#!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
[[ UPDATE ]]
[[ UPDATE ]]
I deleted:
.bashrc
.bash_profile
.zshrc
and I ran:
chsh -s /bin/bash
I am on a Mac. This should have changed my shell from zsh to bash.
I then started over in a terminal window, to be sure all changes were loaded.
Now, if I run "bundle install" the gems seem to install into vendor/cache/ but I get this error:
Installing paperclip 5.0.0
Gem::InstallError: paperclip requires Ruby version >= 2.1.0.
So I run:
rbenv install 2.1.0
and I run "bundle install" again, and I get the same error.
The ruby version is:
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
Any advice?
If I run:
gem env
I see:
- GEM PATHS:
- /Users/lkrubner/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- /Users/lkrubner/.gem/ruby/2.3.0
I guess this is fixed now. Deleting all of .bashrc and .bash_profile and .zshrc and changing the default shell back to bash and deleting all mentions of rvm and reinstalling rbenv and reinstalling "gem" and then "Bundler" seemed to fix at least some of the problems with paths. And I fixed the issue with Paperclip by doing "gem install paperclip" which I guess installed paperclip globally, but at least it works on my local Mac. Very fragile, but things are working.
I wish I could use Clojure for this project. Every time I tangle with Ruby I end up wrestling with this endless maze of path problems. With Clojure, I am protected by Leiningen, which seems to figure this stuff out with pure magic.
I just ran gem update bundler to fix this issue.
I'm trying to run
env RAILS_ENV=test bundle exec rake db:migrate
and get the following error
Your Ruby version is 2.1.7, but your Gemfile specified 2.2.3
ruby -v
gives me
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
I'm using rbenv, if that matters. rbenv versions gives the following:
system
* 2.2.3 (set by /Users/thatsme/Projects/demoproject/.ruby-version)
So I have no ruby 2.1.7 installed. Spring is not running and I've run rbenv rehash. Then bundler gem is installed.
I'm going nuts on this. Can somebody please tell me why the wrong ruby version is being used? Thanks!
Running the command below helped me somehow:
rbenv exec gem install bundler
Assumption: You are using RVM.
This means there's a ruby version installed outside of RVM.
Clear your rvm rubies by running
rvm uninstall <ruby version>
once you have uninstalled all rvm rubies do ruby -v, if this returns an output specifying a ruby version then thats the root of the problem. Uninstall it with
sudo apt-get remove ruby
Now install your rvm rubies with rvm install <ruby version> and set it as default rvm use <ruby version>
Now install bundler
gem install bundler
And do bundle install
TLDR;
Check really carefully the content of your .bash_profile or .bashrc file.
None of the answers actually solve my problem. So here's my solution.
This is the error that I got:
$ bundle install
Your Ruby version is 3.0.1, but your Gemfile specified 2.7.1
I checked my rbenv setup:
$ rbenv versions
system
2.4.1
2.5.0
2.7.0
* 2.7.1 (set by /Users/setoelka/awesome-project/.ruby-version)
3.0.1
I uninstall the wrong version to probably reveal a new error. I can just install it again later, I was thinking.
$ rbenv uninstall 3.0.1
It does reveal a new error:
$ bundle install
-bash: /Users/setoelka/.gem/ruby/3.0.0/bin/bundle: /Users/setoelka/.rbenv/versions/3.0.1/bin/ruby: bad interpreter: No such file or directory
Ok, that's strange. I can just remove the .gem directory there.
$ rm -rf ~/.gem/
Now another new error:
$ bundle install
-bash: /Users/setoelka/.gem/ruby/3.0.0/bin/bundle: No such file or directory
It seems like my PATH variable is messed up. So I do:
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.27
- RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin20]
- INSTALLATION DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/setoelka/.local/share/gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/setoelka/.rbenv/versions/2.7.1/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/bin
- SPEC CACHE DIRECTORY: /Users/setoelka/.local/share/gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-20
- GEM PATHS:
- /Users/setoelka/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
- /Users/setoelka/.local/share/gem/ruby/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/setoelka/.rbenv/versions/2.7.1/bin
- /usr/local/Cellar/rbenv/1.1.2/libexec
- /Users/setoelka/opt/anaconda3/bin
- /Users/setoelka/opt/anaconda3/condabin
- /Users/setoelka/.cargo/bin
- /Users/setoelka/.gem/ruby/3.0.0/bin
- /Users/setoelka/.nvm/versions/node/v16.5.0/bin
- /Users/setoelka/.rbenv/shims
- /Users/setoelka/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/Apple/usr/bin
So, it's clear I missed something when checking out my .bash_profile file. That's the problem there:
- /Users/setoelka/.gem/ruby/3.0.0/bin
That line was somehow buried under a plethora of settings inside my .bash_profile.
I had the same problem
I needed to run
bundle
to reinstall all my gems. then
bundle exec rails c
I am having problems with conflicting versions of Ruby that I have installed. I had 1.8.6 and then installed 1.8.7 and it has caused problems. I get the following error when trying to run my ruby on rails app:
/usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version (1.8.6) doesn't match executable version (1.8.7) (RuntimeError)
I would like to remove 1.8.7 somehow and just use 1.8.6 but have no idea how to go about doing this.
Ran into this same issue and thought I'ld share my findings. There was a 1.8.7 ruby version installed by an rpm (centos 6.3), and I compiled 1.9.3 from sources and put it in a directory /opt/upnxt/ruby. I changed my environment to:
export PATH=/opt/upnxt/ruby/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
export LD_LIBRARY_PATH=/opt/upnxt/ruby/lib64
export RUBYPATH=/opt/upnxt/ruby/bin
export RUBY_HOME=/opt/upnxt/ruby
export RUBYLIB=/opt/upnxt/ruby/lib64/ruby/1.9.1:/opt/upnxt/ruby/lib64/ruby/1.9.1/x86_64-linux
export GEM_HOME=/opt/upnxt/ruby/lib64/ruby/1.9.1
export GEM_PATH=/opt/upnxt/ruby/lib64/ruby/1.9.1:/opt/upnxt/ruby/lib64/ruby/gems/1.9.1
and then when running:
$ ruby /opt/upnxt/ruby/bin/gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/upnxt/ruby/lib64/ruby/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /opt/upnxt/ruby/lib64/ruby/1.9.1/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/upnxt/ruby/lib64/ruby/1.9.1
- /opt/upnxt/ruby/lib64/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
When running without the 'ruby' command in front, I would get:
$ /opt/upnxt/ruby/bin/gem environment
/opt/upnxt/ruby/lib64/ruby/1.9.1/x86_64-linux/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
from /opt/upnxt/ruby/lib64/ruby/1.9.1/rubygems.rb:31:in `require'
from /opt/upnxt/ruby/lib64/ruby/1.9.1/rubygems.rb:31
from /opt/upnxt/ruby/bin/gem:8:in `require'
from /opt/upnxt/ruby/bin/gem:8
because of the default #!/usr/bin/ruby as stated earlier. I guess that's why one should use "#!/bin/env ruby" as a shebang instead (or "#!/usr/bin/env ruby")
If someone can tell me how to change the "RUBY EXECUTABLE" from the "gem environment" output so I won't need to specify it on the commandline, I would be grateful
cheers,
Gerrit
Yes, setting the path:
export PATH=yourrubypath/bin:$PATH
should do it.
I recommend you install rvm, that way you can run different ruby versions and manage gem sets in a very easy way
The installation instructions are here. However it basically reduces to:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then you can install a newer ruby from source (it will compile it!):
$ rvm install 1.9.1 ; rvm 1.9.1
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
$ which ruby
/home/you/.rvm/ruby-1.9.1-p243/bin/ruby
You can go back to the "system" one doing:
$ rvm system
Just change your $PATH to point to the version you want.
I install ruby from the tarball (and not from the distribuition package). This way I can have several different versions working at the same time, I have just to update the $PATH in the session that I want to use a different version.
Your easiest path and future proof too would be using rvm. Download the version of ruby you want with rvm and make it the default.
Installation: http://rvm.beginrescueend.com/rvm/install/
Making it default:
rvm 1.8.6 --default
The whole process would take not more than 15 minutes. Everything is clearly explained in this. Your environment will be set before you finish watching this podcast:
http://railscasts.com/episodes/200-rails-3-beta-and-rvm