I'm trying to migrate a version of Redmine from backup to a new server; I'm migrating from Redmine 3.2.3 to 3.3.0. I installed the new version of Redmine (from Bitnami Stack) on my new server and everything loads properly. When I move my old database into the new version, I have to run
bundle exec rake db:migrate
to migrate my database. But... bundler can't find rake somehow even though gem list shows it clearly installed. Can I force bundler to use the version of rake that I have installed that it says I don't?
I should mention I've done no customization at all, haven't installed any gems, or changed ruby versions or done anything. This is out of the box Redmine.
I noticed after I made the question that I had two versions of rake installed. I removed both and reinstalled rake 11.1.2 and have the same problem.
You are probably using the wrong ruby binary. Note that, the installers for Bitnami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system.
Also, taking a look at the screenshots you have shared, you were using ruby 1.9.3 when you have executed ruby -v and the Redmine Bitnami Stacks uses ruby 2.1.9. Probably this is the reason of the issue you are having.
If you want to use the ruby (and the other components) shipped with the Bitnami Stack you need to run the following command:
cd *INSTALLDIR*
./use_redmine
This command will open a new console session with the environment configured to use the stack.
There are two things:
ruby gems available via gem list
ruby gems availbale via bundler
When you are using bundle then bundler is looking for gem from Gemfile. You can have multiple gems installed in your system, but when you are using Gemfile then gem version will be taken from Gemfile.lock
Summing up:
$ bundle exec rake ...
require to have rake gem inside Gemfile
$ rake ...
it will take the newest version of rake gem installed in system
I hope it helps you.
This is how I finally got my Redmine upgraded:
A version of ruby outside of the one provided by Bitnami somehow got installed on this machine as well as another version of bundler. The first thing I did was uninstall the apt-get version of bundler. I had to manually remove /usr/bin/bundler and /usr/bin/bundle for $ which bundle to stop finding bundler even after the removal.
I saw that the Bitnami stack's ruby was version 2.1.x but found Ruby 1.9.3 was installed to /usr/bin/ruby1.9.3/ with $ which ruby. I took the commands from here and removed that version of Ruby.
Running $ ruby -v now gave me nothing as Ruby wasn't installed anymore (even though it was in the Bitnami stack). Bitnami's Ruby then had to be (re?)added to my path in ~/.profile. $ ruby -v now gives me the correct version.
$ gem list was no longer telling me that rake was installed. I tried running $ bundle install where Gemfile is but was complaining about mime-types being locked at a lower version and wouldn't do anything. I got around that with $ bundle update but then ran into the infamous nokogiri problem where it complains that everything required by nokogiri isn't installed.
Since I'd dealt with this before (many many times) I went over to the Nokogiri Website's install page and followed the instructions for troubleshooting on Ubuntu:
sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
and now $ bundle update worked on my Gemfile. Redmine upgraded and my users are about as happy as users can get.
Related
When trying to bundle install on a Gemfile that contained only the GitHub Pages gem and nothing else, on Ubuntu 18.04, I got error messages telling me to try installing eventmachine using gem install. That always succeeds, but bundle install still fails. How can I get bundler to see that the gem is installed?
I fixed this after many hours of struggle, by noticing that on the GitHub Pages repo there's a note that says
Important: Make sure you have Bundler > v1.14 by running gem update bundler in your terminal before following the next steps.
I have no idea why this mattered but I removed my ruby packages from Ubuntu and reinstalled them, then installed bundler with rubygems, which gave me a newer version:
sudo apt-get remove ruby
sudo apt-get install ruby ruby-dev
sudo gem install bundler
bundler --version
If anyone knows why I needed that version of bundler, or how I should have diagnosed this faster, I'd be interested to hear it. I'm not new to programming but I'm new to Ruby.
From my understanding it might be the gem you are trying to install requires a specific feature provided by bundler. If you check the change log of bundler there is some changes related to install github based gems on how to correctly read the user git settings. So I think that might be where the problem is from.
I am attempting to use bundle install. I am not a Ruby user - this is my first real foray into even running rake. I'm simply trying to user some packages from ThrowtheSwitch.org that use Rake and so on.
I initially installed ruby several days ago using:
sudo apt-get install ruby-full
This allowed me to use rake with Unity testing framework. Now I'd like to use CMock. the instructions for using CMock say to cd into the directory then
$ bundle install
$ bundle exec rake
So I install bundler using:
$ sudo apt-get install bundler
But then running the bundle install continuously asks me for my password. So I try:
$ gem install bundler
Which fails for write permissions on /var/lib/gems/1.9.1. So I try:
$ sudo gem install bundler
which installs OK so I try the bundle install again. But still get continuously asked for my password. So I try:
$ sudo bundle install
And get a warning that I should not run bundler as root:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
How can I install this properly so that I can run it as expected?
Note: I have seen that there are several other questions on this topic, none of which I understood the answers to so let me underline that I am not a ruby (or even web stack) dev - I need this in layman's terms as much as possible.
Note also: I did see several mentions of RVM and rbenv. I'm not sure if they were incidental to those questions in particular or if one or both is required. I do not currently have either. Am about to research exactly what they are now.
Note the third: My platform is WSL (so Ubuntu, kind of).
I've been working with Ruby only a few weeks now. I'll say, I know where you are. I am not about to help much but will say, to your last question in the comments, that my understanding is that the two commands are different.
My understanding of a short answer.. One can have diff versions of Ruby they need to work with (legacy projects, etc) and not every version of Ruby can run every version of a given gem. For this reason, one can use rbenv or rvm to help manage the art of setting up a project with a particular version of ruby and then installing the needed gems.
I've been working with rvm on my mac and rbenv in linux and find them both similar enough for the simple stuff I've been doing. Installing rbenv on linux proved slightly easier. Once set up properly, sudo is no longer needed to install gems - which is preferred. I would recommend trying one of these and installing per their website instructions. Things should go smoother once set up.
Try running:
gem install bundler
bundle install
I will try to explain how the ruby ecosystem works:
Bundler is a gem - a module - that is installed on top of ruby. Gems are installed using
gem install <gem name>
I would recommend you look at installing a ruby version manager before doing anything else. the two main candidates are RVM and rbenv.
I find RVM is the simpler option for the beginner, but it eats up more space on your hard drive.
check out how to install rvm at https://rvm.io/
alternatively look at rbenv at https://github.com/rbenv/rbenv
after you have installed ruby you can test that it is installed correctly by calling ruby -v from the command line.
After that you can install bundler by calling gem install bundler
Once the gem is installed you should be able to run bundler, however if you are using rbenv you might need to run rehash first
I hope that explanation makes sense - please shout if you have questions.
If you - for some reason - stuck with a system installation of ruby,
this does the job:
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$GEM_HOME/bin:$PATH"
found it elsewhere: https://guilhermesimoes.github.io/blog/using-bundler-with-system-ruby
When I try to bundle install I get the following message:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0
In my Gemfile I have the following:
ruby '2.1.0'
And when I run ruby -v in the console I get:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
What does Ruby 2.1.0p0 mean? What version should I have in my Gemfile and why does the error tell me I have Ruby version 2.0.0?
Run
gem install bundler
or
gem update bundler
which may fix your problem.
For all new installed versions of Ruby you should update or install a new bundler.
In the top-level directory of your project, create a file named .ruby-version containing (wait for it...)
2.1.0
That apparently is the cross-{rbenv,rvm} way of spec'ing the version now.
For me, none of the answers helped. I fixed it closing and opening again the terminal.
If you get this in a Rails project, and you recently upgraded your Ruby version you might have spring still running with the old version of Ruby.
./bin/spring stop
will fix this.
None of the other suggestions was working for me. On the server, I had to do:
rvm --default use [correct version number]
brew cleanup ruby worked for me as I use HomeBrew to install Ruby.
I recently updated Ruby through HomeBrew but HomeBrew did not remove the older version. brew cleanup ruby will delete the older version of Ruby.
the main reason for this problem is your machine and gemfile using a different ruby version
so there is multiple problems and solutions for this issue you can try the below solutions one by one
1- make sure your machine install and use the same version of your gemfile if your machine not using the same one try to install this version using rvm
$ rvm install ruby_version_you_want
make sure the version installed success by using this command
$ rvm list
and if the new version doesn't set as a default you can set it using this command
$ rvm --default use ruby_version_you_want
you can check the current ruby version
$ rvm current
$ ruby -v
2- if you have the same issue check your bundler
$ gem install bundler
or
$ gem update bundler
3- in some cases spring still using the old version so you need to stop it
$ ./bin/spring stop
4- another case you can type
$ gem pristine --all
and try to install bundle again
5- also in some cases after install the updated ruby version you just need to restart your terminal.
6- another solution but I didn't recommend it the top-level directory of your project, create a file named .ruby-version containing your active running ruby version
7- if you still have this problem try to remove ruby and install the updated version only
$ aptitude purge ruby
If you are using Capistrano you should also check your deploy.rb file for the set :rbenv_ruby configuration.
I got this after upgrading with ruby-install. Fixed this with:
gem install bundler
followed by:
$HOME/.rubies/ruby-2.4.1/bin/bundle
It shouldn't be necessary to specify the path as which bundle indicates it's already using this path. But it gives the version error if running bundle without the path. I don't know why?
Thanks for the info about installing / updating bundler but it didn't work for me.
I had to do rbenv rehash
If you are using rbenv to manage your ruby environments you can run rbenv local 2.1.0 within your project directory to set the version of ruby your gemfile asks for.
NONE of the above answers worked for me, but
$ gem pristine --all
did the trick for me
buona fortuna
I struggled with something very similar, just different versions. I finally fixed it by going to RubyGems and placing the latest version of bundler in my gemfile, which currently is:
gem 'bundler', '~> 2.1', '>= 2.1.4'
There was still an issue, but after that, I ran:
gem update --system
And it resolved the mixed-up versions of Ruby in the rails project folder. You may have to restart the terminal before you do this. Also, I commented out the bundler gem file, it appears the gem update --system command is what really resolved it.
I got it from here:
For more advanced projects .versions.conf is supported, where more than the Ruby version can be specified.
Generating .versions.conf:
rvm --create --versions-conf use 1.9.3#my_app
Example .versions.conf:
ruby=jruby-1.6.8
ruby-gemset=my_app
env-JRUBY_OPTS=--1.9
Make sure your server configuration points to the correct ruby installation.
I had already updated my Ruby version in the .ruby-version file and that didn't fix it. ruby -v also showed the correct version, but I had forgotten to update my server config.
For example, with rbenv, NGINX, and Pushion Passenger I had in my NGINX server block:
passenger_ruby /Users/myusername/.rbenv/versions/2.3.1/bin/ruby;
And I needed to change to...
passenger_ruby /Users/myusername/.rbenv/versions/2.3.3/bin/ruby;
Then restarted NGINX and it worked.
This could happen when you install new version of ruby and update .ruby-version and Gemfile to the new version without doing install all the gems for new version of ruby first. So do the
$ bundle install
and you might as well need to source .profile or restart your shell.
If you are using rbenv just run
rbenv local 2.0.0
Then
bundle install
I opened Gemfile and replaced 2.7.1 with my own version of ruby 2.7.0 Everything is okay right now.
Had the same problem and I'm working with rbenv
Those are the steps that helped me fix my problem:
First in terminal, type which bundle. For me this gave: /usr/local/bin/bundle
Again in terminal try which ruby. In my case this gave: /Users/Mahmoud/.rbenv/shims/ruby
The problem here thus is that bundle isn't using the same ruby version from rbenv. So the path needs fixing. In other words I need to tell my terminal to use the rbenv version of bundle when I use bundle install.
So step 3: For me I personally already had the path set in ~/.bash_profile:
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
but apparently this was not enough as I was using zsh. Had to add those same 2 lines to ~/.zshrc as well.
Restart terminal
Now bundle install is working as expected and which bundle gives:
/Users/Mahmoud/.rbenv/shims/bundle
indicating that the problem was just that bundle was using the wrong ruby.
So if you have this problem, just make sure ~/.bash_profile and ~/.zshrc have the correct path by adding the 2 lines indicated above. If this didnt work take a deep dive into paths to make sure that before starting which bundle gives the equivalent of:
/Users/Mahmoud/.rbenv/shims/bundle
Had the same error. Doing the following fixed it. I was using ruby 2.5.5 and rbenv. Upgraded from 2.5.1.
rbenv rehash
gem uninstall bundler
gem install bundler
gem install bundler:1.17.3 (my app needed specific bundler -v 1.17.3)
gem install rails
I solved this problem by updating my ruby version to ruby '2.4.0'
Then bundle install
Simply closing the terminal I was working on and opening a new one worked for me. Sometimes, updates are not effected immediately until a session is closed. I have found this as the case with many rails errors I faced.
I clean and install with that:
sudo gem pristine --all
and install again:
bundle install
I face the error msg
Your Ruby version is 2.5.1, but your Gemfile specified 2.3.0
and solved by the following steps:
open Gemfile which located at your directory.
change ruby '2.3.0' to ruby '2.5.1' and save the Gemfile
go back to items and run bundle update.
the issue is perfectly solved.
I'm working in kali-linux (a linux distro witch is the continuation of Back-Track, based in Ubuntu, just that now is based on Debian wheezy) for some penetration testing. Everything was working just fine, until I decided to update my systems tools. Now whenever I try to run a tool based on ruby, it trows me:
Could not find gem 'ruby-progressbar (>= 1.1.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I proceed to run bundle install but then it comes with Bundler::GemfileNotFound error.
Kali use by default ruby, for using gems. The software don't 'require' any other package but ruby seems not-fully-configured/installed for the problem at hand.
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [i486-linux]
$ rvm
bash: rvm: command not found
$ rbenv
bash: rbenv: command not found
I faced the same problem when I was trying to bundle install without realizing that I was not in the project directory. Make sure you're in the current project directory.
to avoid this error you should be at the root of your application and create GemFile and specify all gems needed in there, and run bundle install
The problem was that for some weird motive Ruby didn't detected that bundler was installed, although the package manager says so.
$ apt-cache policy bundler
bundler:
Installed: 1.3.5-2
Candidate: 1.3.5-2
$ bundle --version
Bundler::GemfileNotFound
I simply run gem install bundler then bundler install as root in the tool root path and everything works as charm.
Do you use rvm or rbenv? If so, make sure you are using a particular ruby version.
For rvm, rvm list and look for an indication next to your ruby version. If the correct one is not listed, run rvm install x.y.z. If the correct one is not selected, run rvm use x.y.z
If you want to segregate your gems for a given project, create a gemset. Otherwise, you should be good to go.
Run gem install bundler. You should not have to do this as sudo. This will install bundler in either the Default rvm gemset, or the selected gemset.
Bundler should now be available and can be run using bundle. This is the same as bundle install.
Try this:
sudo ln -s /var/lib/gems/1.8/bin/bundle /bin/bundle
sudo ln -s /var/lib/gems/1.8/bin/bundler /bin/bundler
Worked for me in debian.
I recently started learning Ruby and Ruby on Rails, and have watched a plethora of getting started materials. I have been finding lately that I keep getting errors where gems won't install or they will be installed but they can't be used for some reason, and I have decided that I want to remove everything down to once again just having Ruby installed and start over with the installation. One training video had me install most of my gems with RVM, so I don't know if that changes anything.
So in short my question is "How to I get rid of RVM, Rubygems, and all installed Gems so that I can start over with just Ruby?"
Edit: I am on Mac OS 10.6
gem uninstall -aIx
Uninstalls all gems without prompt.
Options
-a, --[no-]all Uninstall all matching versions
-I, --[no-]ignore-dependencies Ignore dependency requirements while
uninstalling
-x, --[no-]executables Uninstall applicable executables without
confirmation
From the RVM support site:
RVM installs everything into ~/.rvm.
To remove RVM from your system run 'rm
-rf ~/.rvm'. You may have one additional config file in ~/.rvmrc and
of course the RVM hook in your
bash/zsh startup files.
So, just go to the command line and type rm -rf ~/.rvm
All the installed gems are in the ~/.rvm folders, so doing the above will remove the gems and installed rubies in one go.
Gems you added pre-RVM with the default ruby install can be removed by typing this at the command prompt:
for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
For Windows and Unix copy/paste in command prompt (Ruby 1.9.x).
ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.strip.empty? }"
using RVM, you could just type...
rvm gemset empty GEMSET
where GEMSET is the gemset which you would like to empty. then...
install bundle
yum install bundler and finally
bundle install
rvm implode (see cli docs) seems to work - and it even tells you where to look at for leftovers
This is work for me on Ubuntu 16.04. For me, when I was executing
command rails -v it throw errors because of NameError. I have
installed 3 version of rails (4.2.0, 4.2.6, 5.0.0.1). I was trying
to uninstall unnecessary gem using command gem uninstall rails -v
version number but I won't able to, but I find a way to solve
this problem. In order to uninstall all gems, you have to loop
through all entries in gem list with bash scripting. This method is
very inconvenient. Thanks to Rubygems 2.1.0, you now could do it
with one command.
STEP - 1
Firstly, please make sure you upgrade your Rubygems to 2.1.0 or
newer. For this run this command (Incase you are working on an older
version. You can check your gem version using this command any one
of them gem -v or gem --version)
gem update --system
gem --version
STEP - 2
Run this command in you terminal
gem uninstall --all
Step - 3
Install gem bundles (it is not necessary I think just for
precautions)
gem install bundle
Step - 4
Install the rails on your system using this command
gem install rails -v specific version you want to install you can check the rails version on the official site rails all versions
example :- I have installed rails 4.2.6
version, you install as per requirement.
gem install rails -v 4.2.6
Step - 5
Finally check the version of installed rails framework application
by Using basic command rails -v. It will echoed the current
version of rails frameworks. Enjoy :)
References
http://ruby-journal.com/how-to-uninstall-all-ruby-gems/
http://guides.rubyonrails.org/v4.1/getting_started.html
Step 1:
I first kept running into an error that said:
You don't have write permissions for the /usr/bin directory
To get permission, I became a root user with (this is potentially dangerous for reasons beyond my current understanding):
sudo -s
Credit
Step 2:
Then, I kept running into an error that said:
[gem] cannot be uninstalled because it is a default gem
This allowed me to uninstall everything:
for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
Credit
FWIW, there are some weird cases where gems are installed but not really installed:
This should do the trick reasonably reliably.
gem uninstall -Iax `gem list | grep default | awk '{print $1}'`