I try to create a new Rails application with Rails 4.2:
$ rails _4.2_ new my_app
I get the following error:
/Users/myuser/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in
`to_specs': Could not find 'railties' (= 4.2) - did find:
[railties-4.2.7.1,railties-4.1.10,railties-4.1.5,railties-4.1.0.beta2]
(Gem::LoadError)
These are the railties I have:
$ gem list | grep railties
railties (4.2.7.1, 4.1.10, 4.1.5, 4.1.0.beta2)
Why is it demanding that I use railties 4.2 and not one of the others I have, such as 4.2.7.1?
gem install railties - it should fix your problem. At least it helped me
You get the error because you have explicitly specified that you want to use the rails executable from the gem with version 4.2 on your command line.
Rubygems doesn't resolve approximate versions here. Instead, you have to specify the exact version you want to use (or omit the version from the command line to use the executable from the newest version of the gem installed.
Thus, you can use
rails _4.2.7.1_ new my_app
or (given that Rails 4.2.7.1 is the newest version of the rails gem installed to your computer), you can also just use
rails new my_app
Related
I am newbie with Rails and here is my problem.
I created a new Rails's folder by this command
rails new freelancer --database=postgresql --javascript=webpack
And it gave me this error :
can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException) from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in activate_bin_path'
from /Users/xxx/.gem/ruby/3.1.2/bin/rails:25:in <main>' from /Users/xxx/.gem/ruby/3.1.2/bin/ruby_executable_hooks:22:in eval'
from /Users/xxx/.gem/ruby/3.1.2/bin/ruby_executable_hooks:22:in <main>'
When I checked my ruby version, it gave me this :
ruby 2.6.10p210 (2022-04-12 revision 67958)
When I checked my rails version by the command rails -v, it still show me this error :
can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException)
So I thought that maybe my problem is because of my rails's version it up to date, maybe I must reinstall rails ?
What should I do ? Could you please give me some advices ? Thank you in advance.
This error is railties not installed in your pc. Or your Rube setup is not properly.
Now Try it: install railties gem gem install railties
Than you can crate your new rails application again.
From this line of the error message
/System/Library/Frameworks/Ruby.framework/Versions/2.6
it's saying the ruby version being used is the system installation (that is, the installation that comes with macOS). You almost certainly don't want that.
Try installing ruby using one of the recommended ways.
In my case I'd already installed ruby via the package manager, rbenv.
But ruby -v still referred to the system library (it gave ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22], which isn't one I installed myself), so I changed it with rbenv versions (to see which versions were installed; you can install a new version with rbenv install x.x.x) and then rbenv global x.x.x to set the ruby version. But the method to use will differ depending on how you install ruby. I wrote a longer answer here. Hope it helps.
Everything was working fine, then all of a sudden I was not able to run "rails s" or "rails c" anymore.
I keep getting the following error msg:
The git source https://github.com/plataformatec/devise.git is not yet checked out.
Please run `bundle install` before trying to start your application
I have searched online and they said to run: spring binstubs --all, but this does not work and gives me the same error message as above.
Please help. Last thing I did was push a code to heroku and github. Rails server, console was working fine then this happens.
I have tried running bundle install, it outputs this error
...
Resolving dependencies...............
Bundler could not find compatible versions for gem "railties":
In snapshot (Gemfile.lock):
railties (= 5.0.4)
In Gemfile:
inherited_resources was resolved to 1.11.0, which depends on
railties (< 6.1, >= 5.2)
rails (~> 5.0.0) was resolved to 5.0.4, which depends on
railties (= 5.0.4)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
Take note that I did not do any changes to anything, that's why its so weird. It was working 5minutes earlier then all of a sudden this occurs.
I have restarted my Mac already and issue still persists
From the stacktrace, I see the issue to be with the inherited_resources gem. If you look at the gemspec of this gem for v1.11.0 which you are currently using, you can see where it explicitly states >= 5.2 for railties. However, it appears you running rails 5.0.0 which is tied into 5.0.4 of railties.
To fix this, I suggest fixing the inherited_resources gem to v1.9.0 which can use railties 5.0.4 and then re-run bundle install
gem inherited_resources, "1.9.0"
I was able to fix just by simply uninstall and reinstalling my ruby and running bundle install
rbenv uninstall
rbenv install
gem install bundler
bundle install
rails s
I'm new to Rails, following Michael Hartl's textbook. When I run $ bundle install I get the following error:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.1) ruby depends on
bundler (~> 1.0.0) ruby
Current Bundler version:
bundler (1.7.6)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
I then try $ gem install bundler which works fine:
Successfully installed bundler-1.7.6
Parsing documentation for bundler-1.7.6
1 gem installed
However, this doesn't solve the problem. I'm sensing this has something to do with version problems, but I'm not sure where to go with it...
The following :
In Gemfile:
rails (= 3.0.1) ruby depends on
bundler (~> 1.0.0) ruby
means the version of bundler required is greater than or equal to 1.0.0 but strictly less than 1.1.0. Rails 3 is depending on an old version of bundler. At this point of time, you should try out Rails 4 instead :)
You may read up more about the "version syntax" in http://guides.rubygems.org/patterns/#pessimistic_version_constraint
As #user3927334 has already stated the error you got is due to a version conflict between bundler and rails.
Most likely you have run rails new my_app with an outdated version of the rails gem.
gem install rails -v 4.2.0.beta4
Can be used to install a particular version of Rails. see Installing Rails.
You should then remove your old app and rerun the app generator:
rails _4.2.0.beta4_ new hello_app
If you indent to develop on your local machine I would recommend installing RVM (Ruby Version Manager) (as did previous versions of MH's Ruby on Rails Tutorial.)
It allows you to effortlessly switch between different versions of ruby and different sets of gems.
When I run rails new [application] on Ubuntu 13.10, I get the following error:
Resolving dependencies...
Could not find gem 'coffee-rails (~> 3.2.1) ruby' in the gems available on this machine.
It looks like I have this gem installed though:
$ gem list | grep coffee-rails
coffee-rails (4.0.1)
Any ideas on what's going on?
According to the Bundler page:
The specifier ~> has a special meaning, best shown by example. ~> 2.0.3 is identical to >= 2.0.3 and < 2.1. ~> 2.1 is identical to >= 2.1 and < 3.0. ~> 2.2.beta will match prerelease versions like 2.2.beta.12.
As such, version 4.0.1 of your gem is still not the specified one, that is between 3.2.1 and <3.3.
Just run
bundle install
Or, if you were unable to get a project directory with a valid Gemfile:
gem install coffee-rails --version 3.2.1
And it should install a compatible version.
I figured it out. After I got that error, I just went ahead and ran bundle install on the newly created app folder. It installed the missing dependencies and rails new is working now.
this is the error im getting when i "script/server":
can't activate activesupport (= 3.0.0, runtime) for [], already activated activesupport-2.3.8 for ["rails-2.3.8"]
i THINK whats happening here is that something is trying to call in / active "activesupport" for 3.0.0 ... when the "activesupport" for 2.3.8 is already working?
helps?
thanks!
You need uninstall rails 3.0.0 and activesupport 3.0.0.
You can use some different gemset with rvm by example.
Another solution is using bundler with a specific rails version define inside.
If you use bundler you need launch your server with bundler
bundle exec script/server