larsch / ocra

One-Click Ruby Application Builder
http://ocra.rubyforge.org/
835 stars 83 forks source link

Specifying gemspec in the Gemfile doesn't seem to work. #59

Open davidhooey opened 11 years ago

davidhooey commented 11 years ago

If I use 'gemspec' in the Gemfile to reference the gems in the myapp.gemspec file...

source 'https://rubygems.org'
gemspec

...ocra fails with the following error...

C:/Ruby193/lib/ruby/gems/1.9.1/gems/ocra-1.3.1/bin/ocra:639:in `block in find_gem_files': undefined
method `full_name' for nil:NilClass (NoMethodError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ocra-1.3.1/bin/ocra:597:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ocra-1.3.1/bin/ocra:597:in `find_gem_files'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ocra-1.3.1/bin/ocra:716:in `build_exe'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ocra-1.3.1/bin/ocra:1153:in `block in <top (required)>'

If I explicitly add the gems in the Gemfile all is well.

source 'https://rubygems.org'

gem 'ruport', '>= 1.6.3'
gem 'sqlite3'
gem 'activerecord', '>= 3.2.3'
gem 'memcache-client'

I'm using the following command to build the exe.

ocra --no-autoload --dll sqlite3.dll --gemfile Gemfile --console bin\myapp

Thanks!

unicornzero commented 10 years ago

Thank you for posting this issue. I'm running into the same problem. What approach did you end up taking to work around this?

thisismydesign commented 6 years ago

Same issue here but it represented differently (see #134): https://ci.appveyor.com/project/thisismydesign/appveyor-ocra/build/1.0.6

ERROR: Don't know where to put gemfile <some random file>

and when I tried to set a bundler path explicitly (bundle config --local path <>): https://ci.appveyor.com/project/thisismydesign/appveyor-ocra/build/1.0.9

ocra:42:in `relative_path_from': undefined method `path' for "<ruby path>":String (NoMethodError)
davidhooey commented 6 years ago

Sorry for the extremely late reply. Must have missed the notification. Anyways I ended up creating a temporary gemfile for OCRA to use.

# Temporary gemfile to be used by OCRA.
GEMFILE = 'ocra_gemfile'

# Add gems from gemspec.
ocra_gemfile = File.new(GEMFILE, 'w')
File.open("#{NAME}.gemspec",'r') do |file|
    file.each { |line| ocra_gemfile.write "gem #{$1}\n" if line =~ /spec.add_dependency (.+)/ }
end
ocra_gemfile.close

# Execute OCRA
system("ocra --gemfile #{GEMFILE} --console script_name")

# Cleanup
FileUtils.rm Dir.glob(GEMFILE)