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

ceedling command throws LoadError on Windows #84

Closed
adamjcasey opened this issue Jun 3, 2016 · 22 comments
Closed

ceedling command throws LoadError on Windows #84

adamjcasey opened this issue Jun 3, 2016 · 22 comments

Comments

@adamjcasey
Copy link

adamjcasey commented Jun 3, 2016

This was addressed in #76 but still doesn't work. On Windows we get the following:

$ ceedling
c:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:120:in `require': cannot load such file
 -- pty (LoadError)
        from c:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:120:in `require'
        from c:/Ruby22/lib/ruby/gems/2.2.0/gems/ceedling-0.20.3/bin/ceedling:151:in `<top (required)>'
        from c:/Ruby22/bin/ceedling:22:in `load'
        from c:/Ruby22/bin/ceedling:22:in `<main>'

This is because the rescue is looking for a StandardError. When I change lines 167 and 183 to this:

  rescue LoadError

Then the rescue statements work, but even with popen4 (0.1.2) installed, the following error still occurs:

$ ceedling
c:/Ruby22/lib/ruby/gems/2.2.0/gems/ceedling-0.20.3/bin/ceedling:184:in `rescue in rescue in <top (required)>':
 Could Not Find PTY or POPEN4 gem. Install one or both like 'gem install pty' (RuntimeError)
        from c:/Ruby22/lib/ruby/gems/2.2.0/gems/ceedling-0.20.3/bin/ceedling:169:in `rescue in <top (required)
>'
        from c:/Ruby22/lib/ruby/gems/2.2.0/gems/ceedling-0.20.3/bin/ceedling:150:in `<top (required)>'
        from c:/Ruby22/bin/ceedling:22:in `load'
        from c:/Ruby22/bin/ceedling:22:in `<main>'
@pkazakoff
Copy link

Also seeing this issue on Win 7 with Ruby 2.2.0. Bit of a pain as the eclipse integration doesn't work (while ceedling can fake being Google Test, rake can't).

@mvandervoord
Copy link
Member

Before the require 'popen4' line, if you add require 'rubygems', does the second problem go away?

Thanks for finding the first bug, btw. I'll submit both fixes together when we work this one out. :)

@pkazakoff
Copy link

Same issue:

image

@pkazakoff
Copy link

Upon further inspection, it appears this is a result of POpen4 requiring win32-open3, which is not available for Ruby >1.9.

@mvandervoord
Copy link
Member

Curious. It seems fine on my Win7 box running Ruby 2.2. I'll keep digging. Thanks for the extra info!

@mvandervoord
Copy link
Member

Ah, I see. I installed my version of Ruby originally using the SDK version, so when I installed POpen4, it downloaded the source version and built it for me. That appears to not be an option otherwise. Well, clearly I'll have to build in a backup to the backup. ;)

@tkindy
Copy link

tkindy commented Jul 25, 2016

I'm seeing the same issue with Ruby 2.3.1 on Windows 10. Is there an ETA for a fix for this? Thanks!

@DarkEnergy9
Copy link

I have this same error. Is there a fix for this?
Windows 7 Pro.
Ruby 2.2.5p319
ceedling 0.21.0
rake 11.3
thor 0.19.1

@plinnie
Copy link

plinnie commented Oct 12, 2016

I have the same issue on Windows 10.

ceedling (0.21.0)
did_you_mean (1.0.0)
io-console (default: 0.4.5)
json (default: 1.8.3)
minitest (5.8.3)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (default: 2.0.17)
rake (10.4.2)
rdoc (default: 4.2.1)
test-unit (3.1.5)
thor (0.19.1)

@mvandervoord
Copy link
Member

@DarkEnergy9 and @plinnie , it appears neither of you actually installed the popen4 gem? You might want to try this. If that doesn't work, another option might be to try the popen4-mingw gem. If the latter works better for you, I'd love to know that. I'll update bundler to install that instead.

@plinnie
Copy link

plinnie commented Oct 13, 2016

installing Popen4 does not resolve it. I can't install Popen4-Mingw:
C:\Temp\ceelingtest\temp_sensor>gem install POpen4-mingw
ERROR: Could not find a valid gem 'POpen4-mingw' (>= 0) in any repository

I do see it on rubygems.org. Maybe it is because I have a 64 bit version of Ruby, and this gem is 32 bit?

@plinnie
Copy link

plinnie commented Oct 14, 2016

Hmm.. tried it with Ruby 32 bits:

Fetching: win32-open3-0.3.2-x86-mingw32.gem (100%)
ERROR:  Error installing POpen4-mingw:
      win32-open3 requires Ruby version < 1.9.0.

So, it seems I will need to revert to an old version of Ruby. :-( And even then success is not guaranteed. Is there any way we can resolve this? I'm not against getting my hands dirty, but I am not very familiar with Ruby yet (though I am doing the tutorial). How hard would it be to fix this issue?

@mvandervoord
Copy link
Member

Hey @plinnie, maybe you can try some experiments for me?

You can find your Ruby gem somewhere like this (the details will vary based on the versions installed):

C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\ceedling-0.18.0

In there you will find a bin folder. In the bin folder you will find a file called only ceedling with no extension. Open that with your favorite text editor.

Somewhere near line 150, is this what you see? In particular, I want to verify that there are 4 sets of begin...rescue...end blocks in your codebase. (It's good to make sure we're at the same starting point).

  begin
    require 'pty'

    #if available, we use PTY because it will live-stream our data instead of buffering it all up
    def spawn_command(cmd, &block)
      begin
        PTY.spawn(cmd) do |stdout, stdin, pid|
          begin
            block.call(stdout)
          rescue Errno::EIO
          end
        end
      rescue Exception => e
        STDERR.puts e.inspect unless (e == PTY::ChildExited)
      end
    end

  rescue

    begin

      require 'popen4'

      #if pty wasn't available, we'll use POPEN instead
      def spawn_command(cmd, &block)
        POpen4.popen4(cmd) do |stdout, stderr, stdin|
          begin
            block.call(stdout)
          rescue Errno::EIO
          end
        end
      end

    rescue

      #if neither of these libraries were available, we can just shell out to the command and collect results
      def spawn_command(cmd, &block)
        block.call( `#{cmd}` )
      end
    end

Thanks!

@plinnie
Copy link

plinnie commented Oct 17, 2016

I've checked. It is identical. Not a single character is different

I actually change the
rescue
in
rescue LoadError

and that seems to work. Now I get:

C:/Ruby23/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- curses (LoadError)
        from C:/Ruby23/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/ceedling-0.21.0/bin/ceedling:193:in `<top (required)>'
        from C:/Ruby23/bin/ceedling:22:in `load'
        from C:/Ruby23/bin/ceedling:22:in `<main>'

(never mind -> by tinkering with the ruby install I got the wrong devkit)

@plinnie
Copy link

plinnie commented Oct 17, 2016

Well, that was not so simple to fix. I can not install cursus on Windows. DevKit does not contain it, and there is no pacman in the msys2 environment.

mvandervoord added a commit that referenced this issue Oct 27, 2016
@mvandervoord
Copy link
Member

I'll have to check into what to do about Curses :(

I believe everything else in this thread should be fixed at this point.

@mvandervoord
Copy link
Member

@plinnie, are you able to install from source instead of the gem? If so, can you grab the master and see if it works for you? If not, can you grab the latest gem and then apply the last commit's changes (it's only a few lines). I'd like to know if this makes Ceedling happy without curses.

@plinnie
Copy link

plinnie commented Nov 1, 2016

Okay, I grabbed the latest master. I tried to build it. I had to remove the " curses" dependency from the ceedling.gemspec in order for it to install. Now however, I get:

C:/Ruby23/lib/ruby/gems/2.3.0/gems/ceedling-0.22.0/bin/ceedling:283:in `block in <top (required)>': undefined method `each' for #<String:0x2967cc0> (N
oMethodError)
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/ceedling-0.22.0/bin/ceedling:187:in `spawn_command'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/ceedling-0.22.0/bin/ceedling:282:in `<top (required)>'
        from C:/Ruby23/bin/ceedling:22:in `load'
        from C:/Ruby23/bin/ceedling:22:in `<main>'

When executing ceedling test:all on the temp_sensor example.

I don't know if I actually made a valid gem. Since the description in the readme did not produce one. I actually executed 'gem build ceedling.gemspec' , and then installed that gem. So maybe I did something wrong.

@plinnie
Copy link

plinnie commented Nov 1, 2016

In addition, if I run 'bundle exec rake' (wrongly named 'execute' in the readme), I get this result:

rspec ./spec/system/deployment_spec.rb:25 # Ceedling deployed in a project's `vendor` directory.
rspec ./spec/system/deployment_spec.rb:26 # Ceedling deployed in a project's `vendor` directory.
rspec ./spec/system/deployment_spec.rb:27 # Ceedling deployed in a project's `vendor` directory.
rspec ./spec/system/deployment_spec.rb:28 # Ceedling deployed in a project's `vendor` directory.
rspec ./spec/system/deployment_spec.rb:29 # Ceedling deployed in a project's `vendor` directory.
rspec ./spec/system/deployment_spec.rb:39 # Ceedling deployed in a project's `vendor` directory without docs.
rspec ./spec/system/deployment_spec.rb:40 # Ceedling deployed in a project's `vendor` directory without docs.
rspec ./spec/system/deployment_spec.rb:41 # Ceedling deployed in a project's `vendor` directory without docs.
rspec ./spec/system/deployment_spec.rb:42 # Ceedling deployed in a project's `vendor` directory without docs.
rspec ./spec/system/deployment_spec.rb:43 # Ceedling deployed in a project's `vendor` directory without docs.
rspec ./spec/system/deployment_spec.rb:53 # Ceedling deployed as a gem
rspec ./spec/system/deployment_spec.rb:54 # Ceedling deployed as a gem
rspec ./spec/system/deployment_spec.rb:55 # Ceedling deployed as a gem
rspec ./spec/system/deployment_spec.rb:56 # Ceedling deployed as a gem
rspec ./spec/system/deployment_spec.rb:66 # Ceedling command: `ceedling examples` should list out all the examples
rspec ./spec/system/deployment_spec.rb:81 # Ceedling command: `ceedling example [example]` temp_sensor should be testable

@mchernosky
Copy link
Contributor

I had the same undefined method 'each' for #<String:0x2967cc0> error above when running on Windows (without PTY or Popen). I submitted PR #106 to fix it.

@mvandervoord
Copy link
Member

Thanks Matt. Does this work for everyone who reported a problem now?

@plinnie
Copy link

plinnie commented Nov 7, 2016

It works!!!

However, I still had to comment the following line:

  # s.add_dependency "curses", ">= 1.0.0"

from the ceedling.gemspec

Otherwise it would not install the gem created with gem build ceelding.gemspec

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

7 participants