ocra icon indicating copy to clipboard operation
ocra copied to clipboard

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

Open davidhooey opened this issue 11 years ago • 3 comments

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!

davidhooey avatar Jun 13 '13 15:06 davidhooey

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

unicornzero avatar Oct 01 '14 23:10 unicornzero

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)

thisismydesign avatar Jun 07 '18 14:06 thisismydesign

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)

davidhooey avatar Jun 27 '18 14:06 davidhooey