I'm having trouble creating a new Rails app. I'm using a fresh WSL2 + Ubuntu 18.04 install.
Long story short, I followed the Rails installation procedure from https://gorails.com/setup/windows/10 but when installing bundle using gem install bundler, I end up with 2 bundler versions (2.1.2 and 2.1.4).
If I stick with 2.1.2 webpacker throws an error, so I definitely need to install the newest version. The problem is, when I install 2.1.4 the default version remains 2.1.2, so then I go to cd /.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/specifications/default and remove bundler-2.1.2.gemspec, and then I do a gem install bundler --default to get only v2.1.4 as default:
gem list bundler
*** LOCAL GEMS ***
bundler (default: 2.1.4)
But here is the problem; if I run bundler -v I get:
bundler -v
Bundler version 2.1.2
But the real problem is that, when running rails new, it clearly tries to use 2.1.2 which inevitably fails.
How can I solve this?
Thank you
Try gem uninstall bundler --version 2.1.2.
From the app directory run these commands:
gem install bundler
bundle update --bundler
bundle install
This rebuilds the Gemfile.lock with the correct Bundler version.
EDIT: You can create the directory first with rails new my_rails_app, then do cd .. ; rails new my_rails_app after running the above commands.
Related
I have rails project working on Ubuntu.
Now I installed WSL on another machine and cloned the very same project.
Now when I try to install bundler with
gem install bundler
it installed bundler 2.0.2 and on bundle install it gives error:
Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails (~> 5.0.0)'
Now I looked at the gemfile.lock it was bundled with 1.16.4, I installed it with
gem install bundler -v '1.16.4'
Now I do a simple bundle install, then it uses 2.0.2, so I have to do
bundle _1.16.4_ install
It completed successfully, but now when I am trying to do rails db:create, it says
The git source https://github.com/activerecord-hackery/ransack.git is not yet checked out. Please run bundle install before trying to start your application
What's wrong here?
Uninstall bundler 2.0.2:
gem uninstall bundler -v 2.0.2
If you still have problem, you can use:
bundle exec rails db:create
You can update to using bundler 2.x if possible with:
bundle update --bundler
This will change the BUNDLED_WITH version in Gemfile.lock.
see: https://bundler.io/guides/bundler_2_upgrade.html
You could also set the default bundler version:
bundler config default 1.16.4
gem list bundler
However I have found this to be a bit error prone.
Try to remove all your gems (go to the gems folder of your ruby, remove the specifications folder and the gems folder),
gem list should be more or less empty
gem install bundler
And try to bundle install again from scratch.
I have a problem when running bundle install in the root of sharetribe rails's project. It shows me this error message:
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
I tried installing rvm and installing the 2.3.1 version required to run this project but nothing changes and it still throwing this output.
Have anyone faced this problem before ?
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
Steps to resolve this issue
1)rvm install ruby-2.3.1
2)gem install bundler
3)rvm use ruby-2.3.1
4)Bundle install
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
If you run command ruby -v you can see that you have installed Ruby 2.4.0, when you look at the first line in your Gemfile specifies that you want to use Ruby 2.3.1.
You can do either install Ruby 2.3.1 or replace the first line in your Gemfile to with Ruby 2.4.0.
What does it say when you run bundle env in the terminal?
Is it the same ruby version?
I tried gem install bundler one time i had the same problem and bundle updated and worked.
You can read more about it here.
Good luck!
I am trying to run "bundle update", but I keep getting the error message:
An error occurred while installing rack (2.0.1), and Bundler cannot continue.
Make sure that `gem install rack -v '2.0.1'` succeeds before bundling.
Then I install rack 2.0.1:
sudo gem install rack -v 2.0.1
Successfully installed rack-2.0.1
Parsing documentation for rack-2.0.1
Done installing documentation for rack after 2 seconds
1 gem installed
Then I even ran "rbenv rehash", and I run "bundle update" again and the same error message shows up. How do I get Bundler to recognize the new gem?
Make sure you have the "bundler" installed from the ruby version installed by rbenv first. Then, check the ruby version in that directory. It should be the one that you installed from rbenv or rvm. After these, if you are installing something just don't use sudo before bundle. Because bundle is from the rbenv ruby version. If the rbenv rehash doesn't work, just restart the bash and check.
If the without sudo thing needs permission, you are most likely using the bundler that was installed by your system ruby as sudo gem install bundler.
Try reinstalling bundler without a sudo like gem install bundler and retry.
Even if that doesn't work, remove the Gemfile.lock in your directory. Remove any version of rack mentioned in your Gemfile if any. Just have the gem name like gem 'rack' and try bundle install again. The gem that you could install with sudo was stored for the system ruby, not the one you have installed through rbenv.
When you ran sudo install, your gem most probably got installed under a different directory. When using Rbenv or VRM, you shouldn't use sudo.
First of all you could try uninstalling the gem from your system gems and doing it again without sudo.
Going into extremes you could completely reinstall your rbenv with gems (and while at it switch to RVM, personally I think its easier to manage). After that try to bundle install everything again without sudo and it should work.
I'm trying to bundle install a ruby project in Git Bash but I'm getting the above message.
ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i836-mingw32]
gem -v
2.3.0
New to Ruby so its really frustrating. I'm trying to do the project below
http://www.viralrails.com/?p=25
This happens because you are specifying a Ruby version in your Gemfile (2.3.0) and this version is not installed or is not the current or default version.
Don't remove the line ruby '2.3.0' as someone said above. You app may have dependencies to this version. Do the following:
1) Check if you have Ruby 2.3.0 installed. If you are using rvm this may be done by
rvm list
and if you are using rbenv by
rbenv versions
2) If you don't have this Ruby version in your list of installed versions, then install it by issuing the following command
rvm install 2.3.0
and if you are using rbenv by
rbenv install 2.3.0
3) If you already had Ruby 2.3.0 installed or completed step 2 above, enter your app directory and issue the following command
rvm use 2.3.0
and if you are using rbenv by
rbenv local 2.3.0
Then run
bundle install
and I believe things will be ok.
Hope it helps!
Install bundler after installing ruby 2.4.0.
gem install bundler
If you installed bundler before installing ruby 2.4.0 then you should reinstall bundler or update it.
Also if the above command didn't work.
gem update bundler
I am deploying a rails app to EC2 with using Capistrano, but within the deployment process, I got
...
ERROR: Gem bundler is not installed, run `gem install bundler` first.
command finished in 344ms
*** [deploy:update_code] rolling back
...
I am not sure what's the problem, here's the list of installed gems on EC2:
bundler (1.3.5)
rake (10.0.4)
rubygems-bundler (1.1.1)
rvm (1.11.3.7)
ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
Can anyone give me a tip how to fix it?
Thanks
Can you give some details:
Are you using rvm ?
What is the rails version in your Gemfile ?
Gem version ?
If you are using rvm, check for the gemset being used, remove .bundle and do a fresh $ bundle to install the gems.
Post the entire o/p from command $ gem list from your project folder.