I am going through the open-source Spree commerce tutorial. I am new to Ruby, so I just installed Ruby 2.7.2 and Rails 6.1. Unfortunately, Spree doesn't support Rails 6.1 yet, as described here: Bundler could not find compatible versions for gem “rails”.... So, I followed the solutions provided on that SO post and modified my Gemfile to set rails (and railties) to 6.0.3. That seemed to fix the error mentioned on that SO post...
But now when trying to run the command from the tutorial
"bundle exec rails g spree:install --user_class=Spree::User", I'm getting the error:
C:/Program Files/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.0.3/lib/rails/application/configuration.rb:156:in `load_defaults': Unknown version "6.1" (RuntimeError)
Why is this happening, and how do I resolve this error?
Thank you in advance!
Get to the config/application.rb file in your app's folder and set the line with
config.load_defaults 6.1
to the below
config.load_defaults 6.0
The problem is, when you initially ran rails new command, the generators set the rails version to 6.1, which doesn't change when you specified 6.0.0 as version in Gemfile.
Environment
Ruby [1.9.3p547]
Rails [3.2.22.5]
Devise [3.0.4]
When i run any rails or rake command for this application it is giving me below error
/config/initializers/devise.rb:3:in <top (required)>': undefined
methodsetup' for Devise:Module (NoMethodError)
If i comment file devise.rb and run rails command again.
/config/initializers/doorkeeper.rb:1:in `':
uninitialized constant Doorkeeper (NameError)
And so on if i comment doorkeeper.rb file it is giving me error for
/config/initializers/kaminari_config.rb:1:in `':
uninitialized constant Kaminari (NameError)
i can't get what is issue with my application i am unable to perform any rake or rails. its directly giving me error of uninitialized constant .
The ruby and rails version is very old. I don't want to upgrade it. Earlier i though it was issue of devise gem. but it must not be issue of devise gem.
Please help me if any one has idea about this type of error.
Thanks in advance
I think you have some installation issues. Please try to install from scratch.
Follow these steps.
Find version of bundler from Gemfile.lock
Install bundler with that version and continue with bundle install
Check for API_KEY and values in your initializers.
Check for Gem support for your Ruby version (as it is too old)
I have a rails application running rails 3.0.20 and ruby 1.8.7
i want to upgrade to 1.9.3.
the stages i toke in order to start the process are so:
rvm user ruby-1.9.3
rvm gemset create upgradegems
rvm use ruby-1.9.3#upgradegems
now... i ran bundle. and i have a conflict with the twitter gem and the omniauth gem
so i updated them both.
then ran bundle again and it succeeded
now what?..
i tried running
rails s
and i got this error:
ruby-1.9.3-p194#amazonto/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library': uninitialized constant Gattica::Auth::VERSION (NameError)
what am i doing wrong? and how do i fix?
thanks
Its not really your code, but its the library you are using Gattica, it wasn't updated for three years, try to put this on your Gemfile
gem "gattica", :git => "https://github.com/chrisle/gattica.git"
That's a fork that works great with ruby 1.9.x
I have installed ruby 1.9.3p194. I have also installed rails 3.2.8,3.2.6,and 3.0.3. I am able to create a new site using rails versions 3.2.8 and 3.0.3. When I try to create a site with rails 3.2.6 it rails to work.
rails _3.2.6_ new example
/Users/Dave/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb:317:in `bin_path': can't find gem rails (["3.2.6"]) with executable rails (Gem::GemNotFoundException)
from /Users/Dave/.rvm/gems/ruby-1.9.3-p194/bin/rails:19:in `<main>'
from /Users/Dave/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/Dave/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
I have tried uninstalling 3.2.6 and reinstalling but the result is the same. Any help would on this would be great.
UPDATE: I was able to solve this problem by uninstalling both 3.2.6 and 3.0.3 and then reinstalling 3.2.6. Not sure why this worked but it does. At some point I need to install 3.0.3 can these versions not co-exist?
After spending some time looking at gemsets that was definitely the solution to this problem. I set up RVM and installed two versions of Ruby. Then I setup gemsets for each version that had the version of rails I needed to write code for the book I was working through and the web server I am using.
When I want to create a Ruby on Rails project, I get the message below.
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support.rb:57
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails_generator.rb:31
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.8/bin/rails:15
from /usr/bin/rails:19:in `load'
from /usr/bin/rails:19
What has gone wrong? How do I to fix it?
In case you can't upgrade to Ruby on Rails 2.3.11 (and to expand on douglasr's answer), thread must be required at the top of boot.rb. For example:
require 'thread'
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
...
I was able to fix this by downgrading RubyGems to 1.5.3, since it happens with RubyGems 1.6.0+ and Rails < 2.3.11:
gem update --system 1.5.3
If you had previously downgraded to an even earlier version and want to update to 1.5.3, you might get the following when trying to run that:
Updating RubyGems
ERROR: While executing gem ... (RuntimeError)
No gem names are allowed with the --system option
If you get that error, then update, so that it lets you specify the version, and then downgrade again:
gem update --system
gem update --system 1.5.3
This is an incompatibility between Rails 2.3.8 and recent versions of RubyGems. Upgrade to the latest 2.3 version (2.3.11 as of today).
You can also likely get around this issue by requiring 'thread' in your application as such:
require 'thread'
As per the RubyGems 1.6.0 release notes.
If you want to keep your version same like rails will be 2.3.8 and gem version will be latest. You can use this solution Latest gem with Rails2.x. in this some changes in boot.rb file and environment.rb file.
require 'thread' in boot.rb file at the top.
and in environment.rb file add the following code above the initializer block.
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.3.7')
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
I have faced this problem in many occassions when I try to start an old rails 2.3.5 project after having worked with rails 3>. In my case to solve the problem, I must do a rubygems update to version 1.4.2, this is:
sudo gem update --system 1.4.2
If you're using Radiant CMS, simply add
require 'thread'
to the top of config/boot.rb.
(Kudos to Aaron's and nathanvda's responses.)
As mentioned this occurs when using RubyGems 1.6.0 with Ruby on Rails version earlier than version 3. My app is using Ruby on Rails 2.3.3 vendored into the /vendor of the project.
No doubt an upgrade of Ruby on Rails to a newer 2.3.X version may also fix this issue. However, this problem prevents you running Rake to unvendor Ruby on Rails and upgrade it.
Adding require 'thread' to the top of environment.rb did not fix the issue for me. Adding require 'thread' to /vendor/rails/activesupport/lib/active_support.rb did fix the problem.
Try updating your Ruby on Rails version to v3.0.5:
gem install rails --version 3.0.5
or v2.3.11:
gem install rails --version 2.3.11
If this isn't a new project you'll have to upgrade your application accordingly. If it was a new project, just delete the directory you created it in and create a new project again.
update the rubygems
gem update --system
I'm posting my solution for the other sleep-deprived souls out there:
If you're using RVM, double-check that you're in the correct folder, using the correct ruby version and gemset. I had an array of terminal tabs open, and one of them was in a different directory. typing "rails console" produced the error because my default rails distro is 2.3.x.
I noticed the error on my part, cd'd to the correct directory, and my .rvmrc file did the rest.
RVM is not like Git. In git, changing branches in one shell changes it everywhere. It's literally rewriting the files in question. RVM, on the other hand, is just setting shell variables, and must be set for each new shell you open.
In case you're not familiar with .rvmrc, you can put a file with that name in any directory, and rvm will pick it up and use the version/gemset specified therein, whenever you change to that directory. Here's a sample .rvmrc file:
rvm use 1.9.2#turtles
This will switch to the latest version of ruby 1.9.2 in your RVM collection, using the gemset "turtles". Now you can open up a hundred tabs in Terminal (as I end up doing) and never worry about the ruby version it's pointing to.