cbeer / engine_cart

Rake tasks to generate test applications for Rails Engines
MIT License
18 stars 16 forks source link

Engine Cart modifies bin/rails in gem path #9

Closed jeremyf closed 10 years ago

jeremyf commented 10 years ago

When running rake engine_cart:generate with a published gem in pre status (i.e. VERSION="0.0.1.pre"), the bundle install of task :generate, within_test_app (https://github.com/cbeer/engine_cart/blob/master/lib/engine_cart/tasks/engine_cart.rake#L73) obliterates the bin/rails in the rvm gemset. Changing the following file's reference of 'railties' to 'mygemname' (i.e. ~/.rvm/gems/ruby-2.0.0-p353/bin/rails lines 22 and 23). With an exception of Could not find 'harbinger' (= 4.0.3) among 645 total gem(s) (Gem::LoadError) (notice the reference to Rails 4.0.3 gem version).

#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/
    version = $1
    ARGV.shift
  end
end

gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
jeremyf commented 10 years ago

This is manifesting in Travis CI: https://travis-ci.org/jeremyf/orcid/builds/24462163

With the following .travis.yml configuration:

language: ruby
rvm:
  - "2.0.0"

env:
  global:
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true

script: 'rake spec:travis'

bundler_args: --without headless debug

before_install:
  - gem install bundler
jeremyf commented 10 years ago

It appears that the presence of bin/rails in the Engine is causing issues with EngineCart and RVM.

jeremyf commented 10 years ago

Though it appears that RVM may not have a hand in this.

Gemspec created via rails plugin new

  s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
  s.test_files = Dir["test/**/*"]

Relevant gemspec files created via bundle gem new

  spec.files         = `git ls-files -z`.split("\x0")
  spec.executables   = s.files.grep(/^bin\//) { |f| File.basename(f) }
  spec.test_files    = s.files.grep(/^(test|spec|features)\//)
  spec.require_paths = ['lib']

Rails plugins deliberately ignore the bin directory, whereas bundler does not.