You mean "RubyInstaller" ?
> I run C:\Ruby193\lib\ruby\gems\1.9.1\gems\RubyInline-3.11.2\demo\hello.rb
>
> RubyInLine fails : "RubyInline-3.11.2/lib/inline.rb:594:in ``': No such file
> or directory - gcc -shared -O3 -fno-omit-frame-pointer [etc.]"
> In RbConfig I read : "LDSHARED"=>"gcc -shared $(if $(filter-out -g
> -g0,-g),,-s)"
>
> I don't find anything to help me from RubyInLine pages, and I am not very
> comfortable in english and system.
> Please, what should I do ?
>
That is a known issue of RubyInline caused by non-expanded information
of RbConfig.
You can solve this by manually editing rbconfig.rb and change the
value of LDSHARED key.
Steps:
1) Locate rbconfig in your system.
In my case, I used "gem":
C:\Users\Luis>gem which rbconfig
C:/Users/Luis/Tools/Ruby/ruby-1.9.3-p155-i386-mingw32/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb
2) Open that file in your editor.
3) Search for CONFIG["LDSHARED"] in the file (for Ruby 1.9.3 should be
around line 94)
4) Remove the non-expanded logic:
Change:
CONFIG["LDSHARED"] = "$(CC) -shared $(if $(filter-out -g
-g0,$(debugflags)),,-s)"
To:
CONFIG["LDSHARED"] = "$(CC) -shared "
(please note the space before the double quotes)
5) Save the file
6) Try RubyInline again.
Hope that helps.
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
I don't understand what you say here, but I guess since you changed
LDSHARED in rbconfig.rb (bellow) you found the file.
That is incorrect.
The file libmsvcrt-ruby191.dll.a will be used by GCC when
-lmsvcrt-ruby191 is issued.
LD (the linker) will try to find lib<name>.dll.a and then lib<name>.a
libraries for the <name> you supplied to the -l parameter.
The problem you're getting is other: not finding GCC.
Have you invoked "devkitvars.bat" before attempting to compile?
By default DevKit will only be triggered during gem installation and
normally is not in the PATH, even if you decided to add Ruby to the
PATH.
"devkitvars.bat" is inside the DevKit directory, try calling it before, example:
C:\Users\Luis>C:\DevKit\devkitvars.bat
...
[now try RubyInline example again]
The devkitvars.bat should work from any place.
Please copy the example code outside the gem and use "ruby demo.rb".
Sorry for top posting. Sent from mobile.
--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyinstaller/-/BRB2y8prdAgJ.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.
Also, please provide the exact output you get when you say "does not work". With that we can help you better.
Sorry for top posting. Sent from mobile.
> -----------------------------------
> In command line, after C:\DevKit\devkitvars.bat, the program copie-hello.rb
> works ok as below between the hyphens lines :
> -----------------------------------
>
> When I open C:\Users\super\Desktop\Test-RubyInLine and I click on the name
> of the file C:\Users\super\Desktop\Test-RubyInLine\copie-hello.rb, execution
> start and fails.
That will fail since double-clicking the .rb file will not load GCC in
the PATH, which is required by RubyInline to compile the extension
properly.
> When I run C:\Users\super\Desktop\Test-RubyInLine\copie-hello.rb from SciTE
> I get : (below between the hyphens lines)
> -----------------------------------
>>ruby copie-hello.rb
> C:\Users\super\Desktop\Test-RubyInLine
> *
> PATH=C:\Program Files (x86)\ImageMagick-6.6.9-Q16; [ ... ]
> C:\Ruby193\bin;C:\Ruby192\bin
> **
> ***
> C:/Ruby193/lib/ruby/gems/1.9.1/gems/RubyInline-3.11.2/lib/inline.rb:594:in
> ``': No such file or directory - gcc -shared -O3 -g -Wextra
> -Wno-unused-parameter -Wno-parentheses -Wno-long-long
> -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings
> -Werror=declaration-after-statement -Werror=implicit-function-declaration
> -L. -I C:/Ruby193/include/ruby-1.9.1 -I
> C:/Ruby193/include/ruby-1.9.1/i386-mingw32 -I C:/Ruby193/include
> -LC:/Ruby193/lib -o
> "C:/Users/super/.ruby_inline/ruby-1.9.1/Inline_Hello1_203ad5ffa1d7c650ad681fdff3965cd2.so"
> "C:/Users/super/.ruby_inline/ruby-1.9.1/Inline_Hello1_203ad5ffa1d7c650ad681fdff3965cd2.c"
> -Wl,--enable-auto-import -LC:/Ruby193/lib -lmsvcrt-ruby191 (Errno::ENOENT)
> from
Same for SciTE, SciTE knows nothing about where GCC is or how to add
it to the PATH.
If you find it annoying that you can't double click the rb files or
use SciTE, you can require "devkit" on top of your script:
require "devkit"
That way, DevKit will be loaded without the need to run devkitvars.bat before.
But will make your script be somehow limited to RubyInstaller and
DevKit be present, so be warned about that.
That is a good question. Once devkit gets installed it install two
files, which are listed when doing `ruby dk.rb install`, one is used
by RubyGems and the other is devkit.rb
Perhaps we need to document it properly.
The existing DevKit documentation at
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
currently documents the files installed and typical usage scenarios.
The last bullet of "4. Run Installation Scripts" lists the files
installed. The "Hacky Developer Scenario" subsection of "Example
Native RubyGem Installations using the DevKit" shows how one might use
`-rdevkit`.
For the situation in which one doesn't read the documentation we've
taken the time to create, we can't do much about that other than
remind them to read our documentation when they run into problems.
However, I do think our current summary is too cryptic, especially for
newcomers. And it certainly does not mention `require devkit` usage
in script; it assumes you already know that if `-rdevkit` can be used
from the command line, `require devkit` can be used in a script.
That's a bad assumption on our part.
@jfaset what wording do you think would have been more understandable
and saved you time? BTW, please don't be uncomfortable with your
english, it is very understandable :)
Jon
On Thursday, April 12, 2012 5:49:00 AM UTC-5, jfacet wrote:
People who use Linux (or Ipad ?) are young and clever.People who use Windows are many, they hardly now what is a command line and MS-DOS.I don't know why Microsoft has given up Ruby (and Python) after some help.I don't know why when I go to the bookstore specialised in Computers & Technology, Ruby books have been replaced by Python books in 2012.
When I write a ruby program it does not work. I don't how to debug it from the command line. I thought it was not possible. I use SciTE which print errors. Using SciTE is not so easy (coding characters, using gets). And I don't know where I can learn what -rdevkit means.
Perhaps a little place should be given for newcomers using Windows, with a little ruby script as exemple. There is no reason to think the one for which you gave me help is a good one.
Yet I have to know more about config.rb, ENV (Object class) , changing ENV["PATH"].Thank you.
However, I do think our current summary is too cryptic, especially for
newcomers. And it certainly does not mention `require devkit` usage
in script; it assumes you already know that if `-rdevkit` can be used
from the command line, `require devkit` can be used in a script.
That's a bad assumption on our part.@jfaset what wording do you think would have been more understandable
and saved you time? BTW, please don't be uncomfortable with your
english, it is very understandable :)
While the command line culture comment is valid, part of the issue is the MRI Ruby project has historically done a poor job of promoting and supporting Ruby on Windows as a first class citizen.
Many newcomers find a wealth of *nix examples and blogs showing Ruby's quirks on Linux, et al, but not as many on Windows. Some Rubyists think they're being clever when they make degrading comments like "winbloze, windoze, etc". They fail to see that they're harming Ruby by ridiculing Ruby running on Windows. It's a bit like ridiculing your younger brother because he likes to wear cobalt blue and you like to wear red.
This really is a shame and can lead a newcomer to believe that Ruby on Windows just doesn't work. Nothing could be further from the truth as both this project and JRuby shows.
The fact is, it's Ruby we primarily care about rather than a specific OS. OS's do matter, but at the level we're talking about, we want a great Ruby experience regardless of which OS we're using.
As you get more experience with MRI on Windows you find that there is a _lot_ of Windows specifics in the core code. There's Windows specific code in RubyGems and many other widely used gems. There's very experienced committers on ruby-core that care about Windows-specific issues.
Rather than continue down this path, I'll leave it by simply saying this. Have patience, google and use the available documentation, learn how to best use RubyInstall + DevKit for a fun Ruby on Windows experience, and share your experiences to help other newcomers. Blog, tweet, enhance our wiki documentation, find ways to contribute, etc.
> However, I do think our current summary is too cryptic, especially for
> > newcomers. And it certainly does not mention `require devkit` usage
> > in script; it assumes you already know that if `-rdevkit` can be used
> > from the command line, `require devkit` can be used in a script.
> > That's a bad assumption on our part.
> >
> > @jfaset what wording do you think would have been more understandable
> > and saved you time? BTW, please don't be uncomfortable with your
> > english, it is very understandable :)
> >
> @Jon How about something like,
>
> Alternatively you can load the devkit environment programmatically using
> 'require devkit'.
Short and to the point :)
Please update the DevKit wiki page and we'll keep refining as needed. Make sure there's quote's around 'devkit'...`require "devkit"`.
> That being said, why doesn't operating_system.rb just use 'require devkit'?
The two files injected into your Ruby environment when you run `ruby dk.rb install` serve two different purposes.
operating_system.rb is a standardized way to enhance RubyGems (RG) behavior. It exists to automagically pull in the DevKit artifacts when you are installing a gem with native extensions. It's a convenience so that you don't have to remember special command line invocations when installing/updating.
Here's the operating_system.rb from one of my Rubies. Basically, it adds a pre_install hook to RG that tweaks PATH and other env vars only when installing/updating a gem with native extensions. A sublety is that the DevKit artifacts are available only for as long as they're needed to install/update a native gem and do not remain to pollute your PATH and potentially cause other problems.
# :DK-BEG: override 'gem install' to enable RubyInstaller DevKit usage
Gem.pre_install do |gem_installer|
unless gem_installer.spec.extensions.empty?
unless ENV['PATH'].include?('C:\\DevKit\\mingw\\bin') then
Gem.ui.say 'Temporarily enhancing PATH to include DevKit...' if Gem.configuration.verbose
ENV['PATH'] = 'C:\\DevKit\\bin;C:\\DevKit\\mingw\\bin;' + ENV['PATH']
end
ENV['RI_DEVKIT'] = 'C:\\DevKit'
ENV['CC'] = 'gcc'
ENV['CXX'] = 'g++'
ENV['CPP'] = 'cpp'
end
end
# :DK-END:
The other DevKit installed file (devkit.rb) is meant to be _manually_ required rather than being an RG helper. It brings the DevKit artifacts onto PATH, etc whenever you add it to a script via `require "devkit"` or from the command line via `-rdevkit`. It's meant to help scenarios like those documented in the DevKit wiki page as well as this thread's issue. Note that unlike operating_system.rb, the DevKit artifacts can remain on PATH and the other env vars for a longer time period. Here's the devkit.rb on my system:
# enable RubyInstaller DevKit usage as a vendorable helper library
unless ENV['PATH'].include?('C:\\DevKit\\mingw\\bin') then
puts 'Temporarily enhancing PATH to include DevKit...'
ENV['PATH'] = 'C:\\DevKit\\bin;C:\\DevKit\\mingw\\bin;' + ENV['PATH']
end
ENV['RI_DEVKIT'] = 'C:\\DevKit'
ENV['CC'] = 'gcc'
ENV['CXX'] = 'g++'
ENV['CPP'] = 'cpp'
Jon
Forgot to add that, even though the purpose of the two files is different, we may be able to DRY up operating_system.rb by putting `require "devkit"` inside the `unless gem_installer.spec.extensions.empty?`.
Interesting idea.
If you want to tweak on it yourself, here are the relevant sections in part of the DevKit build recipe:
https://github.com/oneclick/rubyinstaller/blob/master/resources/devkit/dk.rb.erb#L46-81
Jon
Uh-oh...curiosity killed me and I manually hacked my existing operating_system.rb ;)
C:\>type \ruby193\lib\ruby\site_ruby\1.9.1\rubygems\defaults\operating_system.rb
# :DK-BEG: override 'gem install' to enable RubyInstaller DevKit usage
Gem.pre_install do |gem_installer|
unless gem_installer.spec.extensions.empty?
require 'devkit'
end
end
# :DK-END:
C:\>gem install redcarpet
Fetching: redcarpet-2.1.1.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed redcarpet-2.1.1
1 gem installed
Jon
---
Fail fast. Fail often. Fail publicly. Learn. Adapt. Repeat.
http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums
Thank you for ruby --helpSome basis missed me from the begining. Here is one :In a ruby script you may writesystem 'del C:\Users\%Username%\.ruby_inline\ruby-1.9.1\Inline_Hello1*.*'(%Username% is an environment variable)but you have to write ENV["PATH"] instead ofsystem 'path'
Uh-oh...curiosity killed me and I manually hacked my existing operating_system.rb ;)
That's because each call to Kernel#system spawns a new shell:
http://ruby-doc.org/core-1.9.3/Kernel.html#method-i-system
It isn't as clear as possible, but the term "sub-shell" hints at it.
If you want to change the path Ruby uses, look at FileUtils[0], and
manipulating ENV["path"].
[0] http://ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/index.html
--
Phillip Gawlowski
gplus.to/phgaw | twitter.com/phgaw
A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
-- Leibniz
When you change PATH using ENV, it changes the PATH environment
variable for that process and any child process that gets spawn from
it.
When you change the path in a child process, that change is only
visible to itself and any other child process spawned by that, but
will not be available in the process that spawned it.
So:
ENV["FOO"] = "something"
system "echo %FOO%"
Will work and print "something"
system "SET BAR=abc"
puts ENV["BAR"]
Will not work because the change to ENV is only available to the child process.
Every time you do "system '...'" it spawns a new child process, so it
starts with a fresh copy of environment variables inherited from the
parent process (cmd.exe is the parent of ruby.exe which then is the
parent of the command you spawn with 'system')
When you modify ENV variables in ruby.exe these will not be persisted
in cmd.exe once ruby.exe terminates.
Hope that makes sense and clear all your doubts about it.
If you still have questions, there is plenty of bibliography about
Windows, Process and such that will be a definite good read for you to
get familiar with.
All the examples and what we discussed before, we talk about
environment variables.
This example has nothing to do with environment variables, it changes
the codepage of the host process (cmd.exe), affecting ruby (as child
process of it) and also any other command your fire from it.
Either way, be careful what you do and how you use those commands on
different computers.