larsch / ocra

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

Ocra not building standalone executables from ruby scripts even when provided the gems path as argument #180

Open vivekwebm2020 opened 2 years ago

vivekwebm2020 commented 2 years ago

As I stated in the Question title, I have installed Ruby 3.0 version in Windows 10 64Bit OS and I have coded this program for Password generation and copying the generated password to clipboard(PasswordGenerator.rb):

require 'clipboard'
CHARS = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a + ('!'..'?').to_a
def GeneratePassword(length=16)
    return CHARS.sort_by{rand}.join[0...length.to_i]
end
Clipboard.copy (GeneratePassword 15)

And I have also installed all the necessary gems that could be needed as dependencies and even sub-dependencies with these:

gem install ocra
gem install --install-dir ./gems thor ftools nokogiri rubygems clipboard

But the second command above installed all the dependencies inside (dir of PasswordGenerator.rb)/gems/gems directory instead of (dir of PasswordGenerator.rb)/gems/ folder, but I ignored that as maybe gem install --install-dir sucked once due to glitch.

But now as I try to build standalone executable from PasswordGenerator.rb with ocra in the same directory it gives me this error. I want a permanent solution of this issue with understanding of why and how ocra wasn't able to add the gems even when specified in the build command the extra paths like ocra PasswordGenerator.rb ./gems/gems and threw this error:

path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:693:in `block (3 levels) in find_gem_files': undefined method `relative_path_from' for nil:NilClass (NoMethodError)
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:693:in `select'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:693:in `block (2 levels) in find_gem_files'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:685:in `each'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:685:in `block in find_gem_files'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:627:in `each'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:627:in `find_gem_files'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:755:in `build_exe'
        from path/to/ruby/gems/3.0.0/gems/ocra-1.3.11/bin/ocra:1231:in `block in <top (required)>'