Skip to content
This repository

Generating new rails projects on the edge is painful #7773

Closed
Spaceghost opened this Issue September 27, 2012 · 24 comments

10 participants

Johnneylee Jack Rollins Rafael Mendonça França Xavier Noria Robert Evans Olivier Lacan Brooke McKim D. Deryl Downey Clemens Gruber Steve Klabnik Hasan
Johnneylee Jack Rollins

Problem

When I use this command to generate a new edge application.

  rails new blog --edge

And then I change the Gemfile from this:

source 'https://rubygems.org'

gem 'rails',     :git => 'git://github.com/rails/rails.git', :branch => '3-2-stable'
...

into a truly edge rails project bundle using this (even include the latest passing commit hash as a ref key based on travis ci build statuses):

source :rubygems

gem 'rails', git: 'git://github.com/rails/rails.git'

I run into some more gem issues.

Could not find gem 'activerecord-deprecated_finders (= 0.0.1) ruby', which is required by gem 'rails (>= 0) ruby', in any of the sources.

To which my reponse is gem 'activerecord-deprecated_finders', git: 'git://github.com/rails/rails.git'

The next part that I come up against follows.

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    sass-rails (>= 0) ruby depends on
      railties (~> 3.2.0) ruby

    rails (>= 0) ruby depends on
      railties (4.0.0.beta)

So I update that line in my gemfile to remove the :branch => ''3-2-stable' reference in the Gemfile. Immediately following up with coffee-rails. So to date, the only oddity for the moment is really just that activerecord-deprecated_finders gem.

Now I feel like I'm really close because the bundle finishes. So I go ahead with a risky bundle exec rails s. What happens next is one issue that I believe needs to be changed.

/Users/spaceghost/Projects/testerly/config/application.rb:7:in `require': cannot load such file -- active_resource/railtie (LoadError)

I don't personally think I need to explain this, but we should either require that gem in rails, the generated Gemfile or remove this railtie from config/application.rb:7

I added a simple:

gem 'activeresource', git: 'git://github.com/rails/activeresource', require: 'active_resource' 

But was stopped again by this:

/Users/spaceghost/Projects/testerly/config/application.rb:8:in `require': cannot load such file -- sprockets/railtie (LoadError)

After exploring this a bit, I found that sstephenson/sprockets doesn't include a railtie anymore. It seems to be living in rails/sprockets-rails. This is my relevant gem line, followed by my config/application.rb changes.

gem 'sprockets-rails'
require 'sprockets/rails/railtie'

To recap, there are three problems.

  1. activerecord-deprecated_finders not having a proper gem in rubygems is a problem, so rails should include it in the gemfile for rails itself.

  2. activeresource is still including a railtie in rails when it has been extracted into a gem. Add it to rails' Gemfile or the local project? Maybe just remove the railtie since the gem has been extracted anyways. I :heart: activeresource by the way. I'm glad it's a separate gem.

  3. sprockets no longer has a railtie that I can find. Rails should refer to sprockets-rails and the necessary file to require is sprockets/rails/railtie

After I got past these myself, I successfully launched my rails server instance (rails console is still broken.)

Rafael Mendonça França

This occurs because the script you are using to generate the Rails edge project is the Rails 3.2.x. You need to have the Rails 4.0 gem in your machine.

Rafael Mendonça França

To install clone the Rails repository and run the install.rb script

Rafael Mendonça França

I don't think we have a way to tell the rails 3.2.x executable to generate a full edge application.

@josevalim @wycats thoughts?

Johnneylee Jack Rollins

Hey, I'm running the install.rb script. Is there anything I have to pass to it? I'm getting some fun responses.

Installing activesupport...
ERROR:  Could not find a valid gem 'activesupport-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: activesupport, activesupport-slices, active_support, activesupport-jcache, jactive_support
Installing activemodel...
ERROR:  Could not find a valid gem 'activemodel-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: activemodel-form, activemodel, activemodel-error, active_device, activelogger
Installing activerecord...
ERROR:  Could not find a valid gem 'activerecord-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: ActiveRecord-JDBC, activerecord-mimer, activerecord-uuid, activerecord-lazy, activerecord_enum
Installing actionpack...
ERROR:  Could not find a valid gem 'actionpack-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: actionpack, eactionpack
Installing actionmailer...
ERROR:  Could not find a valid gem 'actionmailer-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: actionmailer, actionmailer_x509, action_mailer_tls, action_mailer_verp, actionmailer-javamail
Installing railties...
ERROR:  Could not find a valid gem 'railties-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: railties
Installing Rails...
ERROR:  Could not find a valid gem 'rails-.gem' (>= 0) in any repository
ERROR:  Possible alternatives: rails-ajax, rails-api, rails-crud, rails-dbi, rails-erd
rm: rails-.gem: No such file or directory
Rafael Mendonça França
ruby install.rb 4.0.0.beta
Johnneylee Jack Rollins

Here's my output from ruby install.rb 4.0.0.beta

Installing activesupport...
Installing activemodel...
Installing activerecord...
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: activerecord requires activerecord-deprecated_finders (= 0.0.1)
Installing actionpack...
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: actionpack requires journey (~> 2.0.0)
Installing actionmailer...
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: actionmailer requires actionpack (= 4.0.0.beta)
Installing railties...
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: railties requires actionpack (= 4.0.0.beta)
Installing Rails...
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: rails requires actionpack (= 4.0.0.beta), activerecord (= 4.0.0.beta), actionmailer (= 4.0.0.beta), railties (= 4.0.0.beta)

So is --edge really about sticking on the edge of your z release, as in x.y.z?

If so, perhaps the documentation of that switch might be updated to reflect that?

Rafael Mendonça França

Actually the install script will not work because of the journey version and the activerecord-deprecated_finders.

Right now there is no a easy way to generate rails 4 application. I'll leave this open to try to cook a solution.

Yes --edge is about sticking on the edge of your release.

Feel free to update the documentation in the docrails project

Rafael Mendonça França

The only way to generate an application using Rails 4 right now:

  • cloning the repository
  • running bundle install
  • running PATH_OF_YOUR_RAILS_FORK/railties/bin/rails new my_rails_4_app

We are close to the beta release so I think this solution is fine until we don't create the release.

Closing this now

Rafael Mendonça França rafaelfranca closed this September 27, 2012
Johnneylee Jack Rollins

I'll go play with that. I might need to have the ticket reopened if things go squirrely.

Thank you.

Xavier Noria
Owner

You normally want also to pass the --dev option so that the Gemfile points to the local checkout.

Robert Evans

Anyone working on this? This has been annoying me while working on another issue.

I can add this to my list after I finish issue #7596

Rafael Mendonça França
Owner

We can't work on this since the 3.2.8 binary doesn't know anything about the Rails 4 dependencies.

Johnneylee Jack Rollins

It's okay that 3.2.8 isn't good with it. I'm working on getting master working. If things don't work out well, can you reopen the ticket?

Rafael Mendonça França
Owner

I think master branch is working fine. But if it doesn't is better to open a new issue

Olivier Lacan

Simple-ish solution assuming you're either using bundle exec (you'll need to prepend it when necessary below) or you have gem binaries set to install in bin and your path pointing there first.

  • mkdir <appname>
  • cd <appname>
  • bundle init (assuming you have bundler installed)
  • add this in Gemfile:
gem 'rails',     github: 'rails/rails'
gem 'journey',   github: 'rails/journey'
gem 'arel',      github: 'rails/arel'
gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders'
  • run bundle
  • check your version with rails -v, it should be Rails 4.0.0.beta. If not and you're using rbenv, try rbenv rehash.
  • run rails new . --edge

Mine failed to bundle initially but after calling it manually everything seemed fine.

Brooke McKim

Following the PATH_OF_YOUR_RAILS_FORK/railties/bin/rails new my_rails_4_app method I then had to edit my Gemfile to remove all the references to '4.0.0.beta' because it doesn't exist for coffee-rails, sass-rails, or rails. I changed them all to just pull from github master.

Robert Evans
D. Deryl Downey

After running the following it worked perfectly fine for me.

cd $HOME/projects/local/
git clone https://github.com/rails/rails.git
cd $HOME/projects/github/ddd
$HOME/projects/local/rails/railties/bin/rails new cstg_rails4 --edge
cd cstg_rails4
bundle install # I had to run this one twice. I have RVM's globalcache enabled, so had to delete the cached version)

Which resulted in:

∴ be rails --version
Rails 4.0.0.beta

be is a bash shell alias I have for bundle exec

Clemens Gruber

What's the reason for this failure if I exchange my default Rails 3.2.9 line with a github: rails/rails line:

clemens.tuxnet :: ~/Rails/pqgruber ‹master› » emacs Gemfile
clemens.tuxnet :: ~/Rails/pqgruber ‹master*› » bundle install --no-deployment --without production
Updating git://github.com/rails/rails.git
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Could not find gem 'activerecord-deprecated_finders (= 0.0.1) ruby', which is required by gem 'rails (>= 0) ruby', in any of the sources.

Does anybody know how to resolve this? Shouldn't switching from default rails to rails master on github in your Gemfile "just work" ?

Adding gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders' to the Gemfile shouldn't be necessary, in my opinion.. if it's really "deprecated" why not remove it completely? Any remaining dependencies?

Steve Klabnik
Collaborator

@clemensg if you're running edge rails, you have to be willing for there to be a little bit of friction.

D. Deryl Downey

@steveklabnik agreed.

@clemensg If you do what I showed up above, you can then copy over your models, views, and controllers. When dealing with the bleeding edge of something, one should not expect clean exchange of baseline engine+gems. You'll need to generate the way I show, then copy over your M/C/V files. Then backtrack looking for logic changes. There will most likely be some going from 3.x to 4.x, just as there was from 1.x to 2.x, and from 2.x to 3.x.

Also, bear in mind that if you are still using ruby 1.8, you will definitely have to do a swap out to Ruby 1.9, as Ruby 1.8 is not supported under Rails 4.x, going forward.

Not sure if you knew this already, but a reiteration shouldn't be a cause for issue.

Clemens Gruber

Thanks, I know how to create a new edge rails app, but I did not understand what the reason for the bundler error above was. The activerecord-deprecated_finders gem is in the rails Gemfile, so why doesn't it get pulled in by bundler?

I also must got confused about the upgrade of existing apps to Rails 4. I thought, existing apps still work, if you "just" adapt this one Gemfile line. Did not know that you have to do a rails new xy for migrating an app to the Rails master branch.

@ddd thanks, I did already read your post above.

Steve Klabnik
Collaborator

Because the activerecord-deprecated_finders gem has yet to be released to RubyGems. As soon as it is, then it will be.

I thought, existing apps still work, if you "just" adapt this one Gemfile line. Did not know that you have to do a rails new xy for migrating an app to the Rails master branch.

You won't, upon the release of Rails 4. And you don't need to do a rails new xy to migrate, that is just one way of doing it.

Hasan

Worked with 1 hiccup, I had to change source https://rubyforge.org to source: http://rubyforge.org. I'm on FreeBSD, if it makes a difference, using ruby 2.0.0b1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.