Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Ubuntu 12.04 64 bits. I've recently installed the ruby1.9.1 package and the wx-ruby gem using :

sudo gem install wxruby-ruby19

in order to install the ruby1.9 compatible version.

So I wrote a ruby script called fenetre_wx.rb (which has already execution right)

#!/usr/bin/env ruby
require "wx"
include Wx

class FenetrePrincipale < App
    def on_init
            Frame.new(nil, -1, "My app in Ruby with WxRuby", Point.new(-1,-1), Size.new(640,480)).show
    end
end

FenetrePrincipale.new.main_loop

No problem when I call

 ruby fenetre_wx.rb

But when I do :

 ./fenetre_wx.rb

I get the following error :

bash: ./fenetre_wx.rb: Aucun fichier ou dossier de ce type

Which can be translated by :

"No file nor directory of this type" :

I've got the French version, but maybe my translation is wrong, so I left the original text.

Does someone know what's wrong ? Thanks in advance.

share|improve this question
    
Check that the ruby version used in both cases is the same one. which ruby vs env | grep ruby –  bbaja42 Oct 15 '12 at 11:32
    
You're right : whereas "which ruby" gave me 'usr/bin/ruby' ; "env | grep ruby" did not give me anything. So how can I correct it ? I've replaced the shabang with /usr/bin/ruby : but no change. –  Laurent BERNABE Oct 15 '12 at 11:43
add comment

2 Answers

up vote 1 down vote accepted

Please make sure that line endings are unix style in your source file and the source doesn't start with the byte order mark. Byte order mark is a three hex number sequence ( 0xef 0xbb 0xbf) which are invisible through any editor. refer to this StackOverflow question for a solution to byte order mark problem. and use dos2unix for line endings conversion.

share|improve this answer
    
Thank you very much : I first used "sed -i '1 s/^\xef\xbb\xbf//' *.rb" then "dos2unix *.rb", and the problem has been solved :) Maybe the problem comes from my Geany editor configuration (though it is in UTF-8) –  Laurent BERNABE Oct 15 '12 at 12:26
    
You're welcome :) If you program with Windows based tools, find an option that lets you edit unix style, I know that Notepad++ is capable of this. And vim/emacs are available on windows. –  cadadr Oct 15 '12 at 12:29
    
I know what went wrong : I edited the source from a virtual box windows guest, before reusing it in Linux. –  Laurent BERNABE Oct 15 '12 at 12:32
add comment

As you mentioned in the comments, replace

#!/usr/bin/env ruby

with

#!/usr/bin/ruby
share|improve this answer
    
That's done : but I still get the same error . –  Laurent BERNABE Oct 15 '12 at 11:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.