Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocra 1.2.0 fails to load 'prawn' gem #24

Closed
bbiker opened this issue Apr 20, 2011 · 14 comments
Closed

Ocra 1.2.0 fails to load 'prawn' gem #24

bbiker opened this issue Apr 20, 2011 · 14 comments
Assignees

Comments

@bbiker
Copy link

bbiker commented Apr 20, 2011

Env: Window XP SP3, ruby 1.9.2 installed using rubyinstaller

Package a script which required the 'rake' gem. Ocra ran fine with no error message. When I tried to invoke the executable I received the following message:
C:/DOCUME1/Owner/LOCALS1/Temp/ocr28.tmp/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: in 'require' no such file to load --- prawn (LoadError) .

from C:/DOCUME~/owner/LOCALS~//Temp/ocr28.tmp/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in 'require' rom C:/DOCUME~/owner/LOCALS~//Temp/ocr28.tmp/src/df_dda.rb:22:in

'

Examination of ocra's output reveals that only the following lines contained "prawn"

a lib/ruby/gems/1.9.1/specifications/prawn-0.11.1.gemspec --- appears twice

m lib/ruby/gems/1.9.1/prawn-0.11.1/
a lib/ruby/gems/1.9.1/prawn-0.11.1/COPYING
a lib/ruby/gems/1.9.1/prawn-0.11.1/HACKING
a lib/ruby/gems/1.9.1/prawn-0.11.1/LICENSE
a lib/ruby/gems/1.9.1/prawn-0.11.1/README

no listing of rb files for the prawn gem.

Use the following program which replicates the problem.

require 'prawn'

puts "Hello world"

the specifications list pdf_reader-0.9.1.gemspec, Ascii85-1.0.0.gemspec, and ttfunk-1.0.1.gemspec as prawn dependencies.
Only pdf_reader rb files are listed in ocra's output.

Assistance in solving this problem is appreciated.

Thank you
Bernard Kenik

@ghost ghost assigned larsch Apr 20, 2011
@larsch
Copy link
Owner

larsch commented Apr 20, 2011

Could you try with 1.3.0-rc1 for me? (gem install ocra --pre) Thanks!

@bbiker
Copy link
Author

bbiker commented Apr 20, 2011

I have loaded 1.3.0-rc1 and used the following script to test the loading of prawn:

code:

require 'prawn'

puts "Hello World"

end of code:

the executable gave an error message: 'require': no such file to load -- prawn (LoadError)

I believe I know the reason for the failure. Prawn's gemspec is incomplete .. it does not have a "s.file" array containing the list of files to load.

I was about to test my theory to prove to myself if am correct. I will let know the result.

By the way, 'prawn' has 3 dependencies: Ascii85, pdf-reader, and ttfunk.
Only pdf-reader loads properly .. Ascii85 and ttfunk gemspec files lack or have an incorrect s.file array.

@bbiker bbiker closed this as completed Apr 20, 2011
@bbiker
Copy link
Author

bbiker commented Apr 20, 2011

On Apr 20, 2011, at 9:47 AM, larsch wrote:

Could you try with 1.3.0-rc1 for me? (gem install ocra --pre) Thanks!

Reply to this email directly or view it on GitHub:
https://github.com/larsch/ocra/issues

I have loaded 1.3.0-rc1 and used the following script to test the loading of prawn:

code:

require 'prawn'

puts "Hello World"

end of code:

the executable gave an error message: 'require': no such file to load -- prawn (LoadError)

I believe I know the reason for the failure. Prawn's gemspec is incomplete .. it does not have a "s.file" array containing the list of files to load.

I was about to test my theory to prove to myself if am correct. I will let know the result.

By the way, 'prawn' has 3 dependencies: Ascii85, pdf-reader, and ttfunk.
Only pdf-reader loads properly .. Ascii85 and ttfunk gemspec files lack or have an incorrect s.file array.

Perhaps you could contact the developers about the deficiencies in the gemspec. You carry more weight than I.
In the case of prawn and ttfunk, the files in the data directory must be included.

Thank you for looking into this problem.

Bernard Kenik
renard@nc.rr.com

PS I tried to reply on github and accidentally closed the issue.

@bbiker bbiker reopened this Apr 23, 2011
@larsch
Copy link
Owner

larsch commented Apr 23, 2011

I am unable to reproduce the problem on my system. I have ruby-1.9.2-p180, ocra-1.3.0-rc1, prawn-0.11.1 installed via "gem install prawn". I'm not sure what caused the gemspec problem on your system.

@larsch
Copy link
Owner

larsch commented Apr 23, 2011

Just updated rubygems to 1.7.2 and reinstalled prawn; that broke it for me too. I've posted a bug on Rubygems.

I've also pushed a change to Ocra that allows you to do this:

ocra prawn_sample.rb c:/appl/rubyinstaller-1.9.2-p180/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/{data,lib}/**/*

@bbiker
Copy link
Author

bbiker commented Apr 23, 2011

On Apr 23, 2011, at 7:39 AM, larsch wrote:

Just updated rubygems to 1.7.2 and reinstalled prawn; that broke it for me too. I've posted a bug on Rubygems.

I've also pushed a change to Ocra that allows you to do this:

ocra prawn_sample.rb c:/appl/rubyinstaller-1.9.2-p180/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/{data,lib}/*/

Reply to this email directly or view it on GitHub:
#24 (comment)

Thank you for working a solution!

Now for the GOOD and BAD news!!!!!

Good news

I installed the latest version of ocra. (gem install ocra --pre, gem 1.7.2)

I build my application -- I had to use the added phrase for both prawn and ttfunk gems since they both have a data directory.

A quick study of the verbose output revealed that all expected files were loaded including the data.

BAD news

I received the load error message: no such file to load -- prawn (LoadError)

I tried 2 more times with and without "require 'rubygems' " ... same result

I have then build for the 2-line program < require prawn"; puts "Hello World" >
now the error become could not create directory ...

I am the only user ... thus the system user never had that error message before

The one thing that concern me is the location -- abput 5 levels up from the src directory

Please let me what else I can and should to help you solve this problem.

@bbiker
Copy link
Author

bbiker commented Apr 25, 2011

On Apr 23, 2011, at 7:39 AM, larsch wrote:

Just updated rubygems to 1.7.2 and reinstalled prawn; that broke it for me too. I've posted a bug on Rubygems.

I've also pushed a change to Ocra that allows you to do this:

ocra prawn_sample.rb c:/appl/rubyinstaller-1.9.2-p180/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/{data,lib}/*/

Reply to this email directly or view it on GitHub:
#24 (comment)

I tried the following experiment to find out the possible cause your suggestion to fails to solve the problem.

Gem Ascii85 is one of Prawn's dependencies. I wrote 2 short scripts to build an exe that requires the Ascii85-1.0.0 gem. Actually they are both identical. I subsequently I appended the log file.

The first script is built as follows:
ocra -- verbose test_ascii85 >> test_ascii85.log

and the second script:
ocra --verbose test_ascii85_a.rb c:\Ruby192\lib\ruby\gems\1.9.1\gems\Ascii85-1.0.0{data,lib}*__ >> test_ascii85_a.log

The first invocation allows the exe to succeed while the second invocation results in the exe to generate a FATAL ERROR.

I ran the log files through a file comparator the following shown below were the only differences found. Perhaps if the gems were not listed as "user-supplied sources files" then ocra could build a successful exe.

=== Adding user-supplied source files first invocation
m src
a src/test_ascii85.rb

=== Adding user-supplied source files second invocation
m src
a src/test_ascii85_a.rb
m src/..
m src/../..
m src/../../..
m src/../../../..
m src/../../../../..
m src/../../../../../..
m src/../../../../../../Ruby192
m src/../../../../../../Ruby192/lib
m src/../../../../../../Ruby192/lib/ruby
m src/../../../../../../Ruby192/lib/ruby/gems
m src/../../../../../../Ruby192/lib/ruby/gems/1.9.1
m src/../../../../../../Ruby192/lib/ruby/gems/1.9.1/gems
m src/../../../../../../Ruby192/lib/ruby/gems/1.9.1/gems/Ascii85-1.0.0
m src/../../../../../../Ruby192/lib/ruby/gems/1.9.1/gems/Ascii85-1.0.0/lib
a src/../../../../../../Ruby192/lib/ruby/gems/1.9.1/gems/Ascii85-1.0.0/lib/ascii85.rb

@larsch
Copy link
Owner

larsch commented Apr 26, 2011

I did not yet release the changed I made to ocra which fixed the ../../..-problem, but they are on github.

@bbiker
Copy link
Author

bbiker commented Apr 26, 2011

On Apr 26, 2011, at 4:25 AM, larsch wrote:

I did not yet release the changed I made to ocra which fixed the ../../..-problem, but they are on github.

Reply to this email directly or view it on GitHub:
#24 (comment)

I just downloaded the latest ocra (gem install ocra --pre) which I assume is the fixed ocra version above.

A very quick test reveals that the prawn gem can be "require"ed within the test.exe. I need to further check wether the
"data" folder and its contents are available within an exe file that use the prawn gems.

Will let you know as soon as I have completed the test.

Thank You

Bernard Kenik
renard@nc.rr.com

@bbiker
Copy link
Author

bbiker commented Apr 26, 2011

On Apr 26, 2011, at 4:25 AM, larsch wrote:

I did not yet release the changed I made to ocra which fixed the ../../..-problem, but they are on github.

Reply to this email directly or view it on GitHub:
#24 (comment)

This is a follow up to this morning e-mail.

I am to sure if I do have the ocra from github -- do not know how to do it.

ran my test script as follows: ocra --verbose test.rb c:/ruby192/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/{data,lib}/*/ > test2.log

no error messages during the building
the log file does show the multi src levels problem as before.
execution of test.exe yields the following error: FATAL ERROR: Failed to create directory 'C:\DOCUME1\Owner\LOCALS1\Temp\ocra58.tmp\src............'.

when I "compile" the test.rb a: ocra --verbose test.rb > test.log
nada error messages
test.exe does exactly what it should do

so my conclusion is that I may be not using the ocra from GitHud

build my scrip without any error messages

when I run my script using ruby , it runs without any error message and produces 5 expected pdf files correctly.

when I run the exe it produces the expected 5 expected pdf files correctly.

However, the following set of error messages occur when producing a pdf file:

C:/DOCUME1/Owner/LOCALS1/Temp/ocr61.tmp/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/lib/prawn/core/pdf_object.rb:37: warning: failed to load encoding (UTF-16BE); use ASCII-8BIT instead
C:/DOCUME1/Owner/LOCALS1/Temp/ocr61.tmp/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/lib/prawn/core/pdf_object.rb:37: warning: failed to load encoding (UTF-16BE); use ASCII-8BIT instead
C:/DOCUME1/Owner/LOCALS1/Temp/ocr61.tmp/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/lib/prawn/core/pdf_object.rb:37: warning: failed to load encoding (UTF-16BE); use ASCII-8BIT instead
C:/DOCUME1/Owner/LOCALS1/Temp/ocr61.tmp/lib/ruby/gems/1.9.1/gems/prawn-0.11.1/lib/prawn/core/pdf_object.rb:37: warning: failed to load encoding (UTF-16BE); use ASCII-8BIT instead

need further investigation on my part.

@bbiker
Copy link
Author

bbiker commented May 1, 2011

Larsch

Sorry that it took a while to get back to you.

I have coded and tested several methods and integrated them in Ocra module.

Overview:

The methods replace the s.files entries with a list of gem files that are requested...but only from the bin, lib, and data directories and their sub directories. The file lists are obtained by scanning the directories. In this manner, ocra no longer needs to rely on the gem author to place the information in the s.files entry of the gemspec. This is done just before ocra reads the s.files entry. The gathering of the list only needs to done once. Once the list has been generated, a "flag" file is placed in the gem's root directory. The flag remains until it is either manually deleted or the gem is uninstalled and a new version installed. The time ocra processes the gem the files list will be obtained and placed in gem's root directory.This minimizes the interference the methods may impose. Actually the gathering of the lists is just one line of code to scan an entire directory tree.

I have tested the methods on Windows XP SP3, ruby-1.9.2, ocra-1.3.1-rc1.

I used Ascii85, ttfunk, pdf-reader, and prawn gems to test the methods as I developed them. The smoke test was the successful compilation of my script. Let's say that I triumphed.

Integration occurs at only one point in ora's code. Extremely easy to undo. Ocra behaves exactly as it originally did.

I hope that you accept and use my contribution to ocra. You done an excellent job, especially since you wrote it in Ruby.
I would not have able to submit a fix to what I considered a fault in ruby2exe.

I have enclosed my version of ocra. The methods are:

Ocra.replace_gemspec_list(gempath, gemfullname)

Ocra.replace_spec_list(file, list)

Ocra.get_spec_list(gem_dir)

Each methods have a brief description of their functions.

The point of integration is: the first line in " gems.each do | gempath, fullgemname | " line 603 in my code listing.

I told you a lie when I said that my script ran without a small hiccup. Prawn issued info messages concerning not having loaded an encoding .... TTF-16BE to be precise. The script continued to completion and all outputs were produced correctly.

After some digging and thinking I determined that prawn required some encoding resource located from one of the built-in module ... aptly named "encoding." The solution is easy but very expensive!!! I use the '--load-all-core' option. A lot of code to shut down info message caused by 2 lines of code.

Would it be possible to load only one built-in module as opposed to the entire set of modules?

Thank You
Bernard Kenik

@bbiker
Copy link
Author

bbiker commented May 7, 2011

Larsch
In my last comment, I asked if it was possible to include one built-in library as opposed to the entire set of built-in (core) libraries.
Reasoning for the request:
The less the exe has to do before running, the faster it will start. The less the exe has to cleanup the faster the exe will finish.
I have answered my own question!!! Yes it is.

I have implemented the solution. I have added two options.
The 1st option: --add-core loads the specified library to the appropriate location.
The 2nd option: --add-core-file <core/file> loads the file from the specified built-in library to the appropriate location.

I believe that the above would resolve some of the problems experienced by users.

I am not that familiar with github -- so what would be the best for me to send my version of ocra executable file?

@CrazyCoder
Copy link

See also issue #26 with a patch which should solve this problem.

@larsch
Copy link
Owner

larsch commented Jun 19, 2011

1.3.0 released, closing issue.

@larsch larsch closed this as completed Jun 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants