From: Paul Lutus Date: 2006-11-26T03:25:10+09:00 Subject: Re: syntax error Une b辿vue wrote: > Paul Lutus wrote: > >> Okay. I successfully ran your code this way: >> >> file = "test.wav" >> >> fxml=file.gsub(/(.*)\.wav/,'\1.xml') >> >> puts fxml >> >> output: >> >> test.xml >> >> So there is nothing wrong with the syntax in the line creating the error >> message. > > OK then we agree... We agree that the line should not have produced an error. We apparently don't agree that your setup (multiple Ruby versions and no clear way to distinguish between them) caused the problem. >> >> What is in RGV[0]? What is the content of the offending line? >> > >> > RGV[0] is a typo of mine, it should be read : >> > ARGV[0] >> >> Please do not retype your code into the newsreader. Instead, copy it >> directly from your programming editor. > > Unfortunately i can't anymore, because, on MacOS X, using "System > Events.app" i did something wrong (?) and cut'n paste and drag'n drop > facilities disappeared... Re-install Mac OS X if you have to. Not being able to post your code as written is very serious. Not being able to cut and paste is even more serious. > That only in my account if i add another one, for this new account, > cut'n paste and drag'n drop are working as expected... Then the problem is limited to your user space. Remedy: back up all your user files, delete your user account, reestablish it, restore your backed-up files. > >> This may be the problem -- the code >> in your programming editor may not be identical to the code you have >> posted, because the code you posted runs fine. > > yes my code works fine even on another computer which i don't know the > OS version nor the ruby version. Okay. Two facts: 1. Your code doesn't work on your machine, but it works on another machine just fine. 2. The way you have of installing and using multiple Ruby versions is "no prob". One of these facts isn't a fact. > someone gave me (other thread in this group if interested see message > 76135, 76138 and 76139 on ruby-talk) it seems to be related to the > shebang i use : > > #!/usr/bin/env ruby # [with or without -w] > > the args given to a ruby script are miss-interpreted by the SHELL. So don't do this any more. Instead, create a symlink located at /usr/local/bin/ruby. Change this symlink when you want to change Ruby versions. > I've discovered that today althought i'm using ruby at least since 3 > years... > > and i'm more or less obliged to use this kind of shebang because the > users No, you are not obliged to do this. You can edit your scripts before delivery. Or you can make rewrite /usr/bin/env to do something special for you WRT Ruby (a less attractive solution). > i've use /usr/bin/ruby for ruby where i use /opt/local/bin/ruby, i > don't want to change anything -- even the shebang -- between my version > and the version for the users... 1. Change your scripts to all refer to /usr/local/bin/ruby. 2. Change your system/user search path to have /usr/local/bin as the first search entry. 3. Put a symlink at /usr/local/bin/ruby, change it as required. 4. Don't use environmental variables. 5. Don't use aliases. 6. Use a Ruby script to edit your scripts, before delivery to your clients, that changes /usr/local/bin/ruby to whatever the client needs to have there. Alternative: create your own version of /usr/bin/env that doesn't mess up the search for Ruby. / ... >> If (1) the code you are running is identical to the code you posted, and >> (2) you are still getting the error message, then (3) you have to get rid >> of two of the three Ruby versions that are now living on your system. > > NO definitely NO the first version is the one used by Apple's OS i don't > want to touch it. Okay, then. Use a symlink. And hope that these various Ruby versions are not writing to the same library locations. > then i need at least a second version to play with gems. > > the second is mine installed in a proper way by MacPort, this is the one > i'm using generally. > > the third is devoted to jRuby and doesn't interfere by anyway with the > others because first it isn't in the PATH, second it's under my HOME, > third it is a somehow "special" ruby for jRuby (ruby 1.8.5 (0) [java]) > and lastly the executable files aren't root:admin as owner:group rather > than yvon;yvon. Your argument seems to be: 1. "I must have multiple Ruby versions." 2. "I can't get my scripts to work." 3. "Help!" As Americans say, something has to give. / ... >> Except that your system will not execute perfectly good code, which means >> the three Ruby versions are not cohabiting nicely -- unless you are >> typing your code instead of copying it. > > not all the prob, i've discovered that this morning comes from Apple's > itself since years (2 to 3) and it's really odd. The fact is that perfectly good code raised an error message, and you do not know why. The error in /usr/bin/env can't cause good Ruby code to produce an error, because it would have selected a Ruby version, and no Ruby version would have rejeted the line you posted. Re-reading ... What? You are saying that the Apple Ruby version is the source of the error? So remove that version of Ruby from your system. Update it, delete it, whatever. Don't you realize that this error-prone Ruby version (if this is what you are saying) may have hundreds of other surprises for you? That this will make it impossible to develop code that can be expected to work reliably anywhere? -- Paul Lutus http://www.arachnoid.com