Mohammad Azam
2009-Jun-16 21:46 UTC
[Ironruby-core] Accessing open-uri from the same directory
Hi, I am have placed open-uri in the same directory as my application and I am trying to include open-uri in my application using the require attribute. require File.dirname(__FILE__) + ''/open-uri'' It throws the following error: C:\ironruby\ironruby\Merlin\Main\Languages\Ruby\Libs>ir test.rb :0:in `require'': no such file to load -- uri (LoadError) from ./open-uri.rb:1 from test.rb:4 from :0:in `require'' Thanks, -- Posted via http://www.ruby-forum.com/.
Shay Friedman
2009-Jun-17 04:11 UTC
[Ironruby-core] Accessing open-uri from the same directory
Hi Mohammad, It happens because open-uri tries to load the uri library and it fails to find it. I couldn''t reproduce this behavior on my end... The uri library should be located at <path_to_merlin>\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8\uri.rb Is there a chance you''re changing the $LOAD_PATH array? By the way, why would you want to copy the open-uri lib to your application directory? The standard library folder is a part of the file lookup paths, so no matter where your application is installed to, the standard libraries (like open-uri) will still be available. Shay. ---------------------------- Shay Friedman http://www.ironshay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Ivan Porto Carrero
2009-Jun-17 07:47 UTC
[Ironruby-core] Accessing open-uri from the same directory
it can be useful when you want to deploy your application to systems where you don''t know if ironruby is installed etc. I''m doing the same for an ironrubymvc application. I still have to find a nicer solution to that maybe by reusing the ironruby configuration to make those paths configurable. --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 6:11 AM, Shay Friedman <lists at ruby-forum.com> wrote:> Hi Mohammad, > > It happens because open-uri tries to load the uri library and it fails > to find it. > > I couldn''t reproduce this behavior on my end... > The uri library should be located at > > <path_to_merlin>\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8\uri.rb > Is there a chance you''re changing the $LOAD_PATH array? > > By the way, why would you want to copy the open-uri lib to your > application directory? The standard library folder is a part of the file > lookup paths, so no matter where your application is installed to, the > standard libraries (like open-uri) will still be available. > > Shay. > ---------------------------- > Shay Friedman > http://www.ironshay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/72fbdae6/attachment.html>
Shay Friedman
2009-Jun-17 08:06 UTC
[Ironruby-core] Accessing open-uri from the same directory
How can IronRuby work if it''s not installed? -- Posted via http://www.ruby-forum.com/.
Ivan Porto Carrero
2009-Jun-17 08:15 UTC
[Ironruby-core] Accessing open-uri from the same directory
it are just DLL''s you could host them inside your own application.ir.exe also calls out to those libraries to do its work --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 10:06 AM, Shay Friedman <lists at ruby-forum.com>wrote:> How can IronRuby work if it''s not installed? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/390703c4/attachment.html>
Mohammad Azam
2009-Jun-17 14:34 UTC
[Ironruby-core] Accessing open-uri from the same directory
I am using the following code to scrape the webpage. button = Button.new button.Text = ''Scrape URL'' button.Location = System::Drawing::Point.new(108,61) button.click do |sender,args| page = File.open("http://www.azamsharp.com/Default.aspx") System::Windows::Forms::MessageBox.Show(page.read) end I get the following error message: Invalid argument - URI formats are not supported -- Posted via http://www.ruby-forum.com/.
Ivan Porto Carrero
2009-Jun-17 14:48 UTC
[Ironruby-core] Accessing open-uri from the same directory
if you have openuri required just remove the File that should work or uri = URI.parse("http://somewhere.com/default.aspx") uri.open do |f| #some logic here end or you could just use open("http://somewhere.com/default.aspx") do |f| # some logic here end taken from http://www.ruby-doc.org/stdlib/libdoc/open-uri/rdoc/classes/OpenURI.html --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 4:34 PM, Mohammad Azam <lists at ruby-forum.com> wrote:> > I am using the following code to scrape the webpage. > > button = Button.new > button.Text = ''Scrape URL'' > button.Location = System::Drawing::Point.new(108,61) > button.click do |sender,args| > > page = File.open("http://www.azamsharp.com/Default.aspx") > System::Windows::Forms::MessageBox.Show(page.read) > > end > > I get the following error message: > > Invalid argument - URI formats are not supported > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/c0ad9504/attachment.html>
Shay Friedman
2009-Jun-17 15:13 UTC
[Ironruby-core] Accessing open-uri from the same directory
You''re trying to use the File class to open URIs which is not supported. Try open instead of File.open (and add require "open-uri" as well). Shay. ---------------------------- Shay Friedman http://www.ironshay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 16:55 UTC
[Ironruby-core] Accessing open-uri from the same directory
If I put: require ''open-uri'' then it throws the error that error locating the file ''open-uri''. I used the following code: def scrape_page() uri = URI.parse("http://somewhere.com/default.aspx") end And now it throws the exception: Unintitialzied constant Object: URI Ivan Porto carrero wrote:> if you have openuri required > just remove the File that should work > or > > uri = URI.parse("http://somewhere.com/default.aspx") > uri.open do |f| > #some logic here > end > > or > > you could just use > > open("http://somewhere.com/default.aspx") do |f| > # some logic here > end > > taken from > http://www.ruby-doc.org/stdlib/libdoc/open-uri/rdoc/classes/OpenURI.html > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero)-- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 17:00 UTC
[Ironruby-core] Accessing open-uri from the same directory
I tried to add a require ''open-uri'' but for some reason it is not able to locate the open-uri files. I have placed the open-uri in the libs folder and I said: require ''libs/open-uri'' but it is not able to locate the file. -- Posted via http://www.ruby-forum.com/.
Ivan Porto Carrero
2009-Jun-17 17:21 UTC
[Ironruby-core] Accessing open-uri from the same directory
what version of ironruby are you using?it looks like your search paths are messed up. for example does require File.dirname(__FILE__) + ''/libs/open-uri'' work? --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 6:55 PM, Mohammad Azam <lists at ruby-forum.com> wrote:> > If I put: > > require ''open-uri'' > > then it throws the error that error locating the file ''open-uri''. > > I used the following code: > > def scrape_page() > > uri = URI.parse("http://somewhere.com/default.aspx") > > end > > And now it throws the exception: > > Unintitialzied constant Object: URI > > > > Ivan Porto carrero wrote: > > if you have openuri required > > just remove the File that should work > > or > > > > uri = URI.parse("http://somewhere.com/default.aspx") > > uri.open do |f| > > #some logic here > > end > > > > or > > > > you could just use > > > > open("http://somewhere.com/default.aspx") do |f| > > # some logic here > > end > > > > taken from > > http://www.ruby-doc.org/stdlib/libdoc/open-uri/rdoc/classes/OpenURI.html > > --- > > Met vriendelijke groeten - Best regards - Salutations > > Ivan Porto Carrero > > Blog: http://flanders.co.nz > > Twitter: http://twitter.com/casualjim > > Author of IronRuby in Action (http://manning.com/carrero) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/63c01872/attachment.html>
Shay Friedman
2009-Jun-17 17:22 UTC
[Ironruby-core] Accessing open-uri from the same directory
Can you check if the open-uri.rb file exists in the folder: <path_to_merlin>\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8\ -- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 17:24 UTC
[Ironruby-core] Accessing open-uri from the same directory
I have placed the open-uri file in the libs folder within the project. But for some reason it blows up and says unable to locate open-uri file. -- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 17:25 UTC
[Ironruby-core] Accessing open-uri from the same directory
I tried with the path and got the following error: require File.dirname(__FILE__) + ''/libs/open-uri'' C:\IronRubyProjects\IronRubyTaskListApplication>ir main_form.rb :0:in `require'': no such file to load -- uri (LoadError) from ./libs/open-uri.rb:1 from main_form.rb:4 from :0:in `require'' Ivan Porto carrero wrote:> what version of ironruby are you using?it looks like your search paths > are > messed up. > > for example does require File.dirname(__FILE__) + ''/libs/open-uri'' work? > > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero)-- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 17:26 UTC
[Ironruby-core] Accessing open-uri from the same directory
Here is the version: C:\IronRubyProjects\IronRubyTaskListApplication>ir -v IronRuby 0.5.0.0 on .NET 2.0.0.0 -- Posted via http://www.ruby-forum.com/.
Ivan Porto Carrero
2009-Jun-17 17:28 UTC
[Ironruby-core] Accessing open-uri from the same directory
ok you also need the uri file open-uri has a dependency on that file. But still I think your search paths are messed up. how does you config look like? Where is ironruby located did you pick a release or build from git? --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 7:25 PM, Mohammad Azam <lists at ruby-forum.com> wrote:> > I tried with the path and got the following error: > > require File.dirname(__FILE__) + ''/libs/open-uri'' > > C:\IronRubyProjects\IronRubyTaskListApplication>ir main_form.rb > :0:in `require'': no such file to load -- uri (LoadError) > from ./libs/open-uri.rb:1 > from main_form.rb:4 > from :0:in `require'' > > > Ivan Porto carrero wrote: > > what version of ironruby are you using?it looks like your search paths > > are > > messed up. > > > > for example does require File.dirname(__FILE__) + ''/libs/open-uri'' work? > > > > --- > > Met vriendelijke groeten - Best regards - Salutations > > Ivan Porto Carrero > > Blog: http://flanders.co.nz > > Twitter: http://twitter.com/casualjim > > Author of IronRuby in Action (http://manning.com/carrero) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/a6ee224b/attachment.html>
Ivan Porto Carrero
2009-Jun-17 17:38 UTC
[Ironruby-core] Accessing open-uri from the same directory
are you hosting ironruby in your application or are you using the ir command to run it? Are the paths correct in ir.exe.config? --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 7:26 PM, Mohammad Azam <lists at ruby-forum.com> wrote:> > Here is the version: > > > C:\IronRubyProjects\IronRubyTaskListApplication>ir -v > IronRuby 0.5.0.0 on .NET 2.0.0.0 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/7129c4c1/attachment.html>
Mohammad Azam
2009-Jun-17 17:48 UTC
[Ironruby-core] Accessing open-uri from the same directory
I am using ir command to run it. It is all ruby code. I went to the C:\ironruby\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8 folder and run the following code: require ''open-uri'' it asked for stringio (not sure why it was missing) so I placed it in the 1.8 folder and ran again and it worked. But now when I use the same files for my project libs/stringio.rb it does not work. C:\IronRubyProjects\IronRubyTaskListApplication>ir main_form.rb :0:in `require'': no such file to load -- uri (LoadError) from ./libs/open-uri.rb:1 from main_form.rb:4 from :0:in `require'' -- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 18:00 UTC
[Ironruby-core] Accessing open-uri from the same directory
Actually I checked using the ir.exe command line and it did not work either. It seems like the C:\ironruby\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8 and C:\ironruby\ironruby\Merlin\Main\Languages\Ruby\Libs contains duplicate rb files. One open-uri is for url and other is for file system. I think the dependencies are messed up! -- Posted via http://www.ruby-forum.com/.
Ivan Porto Carrero
2009-Jun-17 18:07 UTC
[Ironruby-core] Accessing open-uri from the same directory
for me the compiled binaries end up in: C:\tools\ironruby\merlin\main\bin\debug and this is how the relevant tag looks like in that ir.exe.config file <set option=''LibraryPaths'' language=''Ruby'' value=''..\..\Languages\Ruby\libs;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\Ruby-1.8.6p287\lib\ruby\site_ruby\1.8;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\Ruby-1.8.6p287\lib\ruby\site_ruby;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\Ruby-1.8.6p287\lib\ruby\1.8''/> I know it''s lame but it works for me. + C:\tools\ironruby (master) ? ir IronRuby 0.5.0.0 on .NET 2.0.50727.4918 Copyright (c) Microsoft Corporation. All rights reserved.>>> require ''open-uri''=> true>>>--- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, Jun 17, 2009 at 7:48 PM, Mohammad Azam <lists at ruby-forum.com> wrote:> I am using ir command to run it. It is all ruby code. > > I went to the > > C:\ironruby\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8 > folder and run the following code: > > require ''open-uri'' > > it asked for stringio (not sure why it was missing) so I placed it in > the 1.8 folder and ran again and it worked. But now when I use the same > files for my project libs/stringio.rb it does not work. > > > C:\IronRubyProjects\IronRubyTaskListApplication>ir main_form.rb > :0:in `require'': no such file to load -- uri (LoadError) > from ./libs/open-uri.rb:1 > from main_form.rb:4 > from :0:in `require'' > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090617/8595a60b/attachment.html>
Jim Deville
2009-Jun-17 18:14 UTC
[Ironruby-core] Accessing open-uri from the same directory
Usually, the one in> C:\ironruby\ironruby\Merlin\Main\Languages\Ruby\LibsContains hacks or workarounds to load the correct one from> C:\ironruby\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\re > dist-libs\ruby\1.8In other cases, the first one may simply load code from C#. What does your ir.exe.config look like? Thanks, JD ...there is no try> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Mohammad Azam > Sent: Wednesday, June 17, 2009 11:01 AM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Accessing open-uri from the same directory > > Actually I checked using the ir.exe command line and it did not work either. It > seems like the > > C:\ironruby\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\re > dist-libs\ruby\1.8 > > and > > C:\ironruby\ironruby\Merlin\Main\Languages\Ruby\Libs > > contains duplicate rb files. One open-uri is for url and other is for file system. > I think the dependencies are messed up! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
Mohammad Azam
2009-Jun-17 18:20 UTC
[Ironruby-core] Accessing open-uri from the same directory
I have the exact same path in the ir.exe.config file. But I can only run the open-uri if I am in the lib folder where the file is physically located. This is really strange! -- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 18:22 UTC
[Ironruby-core] Accessing open-uri from the same directory
Here is the part of the ir.exe.config file. <microsoft.scripting> <languages> <language names="IronPython;Python;py" extensions=".py" displayName="IronPython 2.6 Alpha" type="IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.10, Culture=neutral, PublicKeyToken=null" /> <language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby" type="IronRuby.Runtime.RubyContext, IronRuby, Version=0.5.0.0, Culture=neutral, PublicKeyToken=null" /> </languages> <options> <set language="Ruby" option="LibraryPaths" value="..\..\Languages\Ruby\libs\;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\site_ruby\1.8\;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8\" /> </options> </microsoft.scripting> -- Posted via http://www.ruby-forum.com/.
Mohammad Azam
2009-Jun-17 18:27 UTC
[Ironruby-core] Accessing open-uri from the same directory
Here is the complete ir.exe.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="microsoft.scripting" type="Microsoft.Scripting.Hosting.Configuration.Section, Microsoft.Scripting, Version=0.9.6.10, Culture=neutral, PublicKeyToken=null" requirePermission="false" /> </configSections> <microsoft.scripting> <languages> <language names="IronPython;Python;py" extensions=".py" displayName="IronPython 2.6 Alpha" type="IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.10, Culture=neutral, PublicKeyToken=null" /> <language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby" type="IronRuby.Runtime.RubyContext, IronRuby, Version=0.5.0.0, Culture=neutral, PublicKeyToken=null" /> </languages> <options> <set language="Ruby" option="LibraryPaths" value="..\..\Languages\Ruby\libs\;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\site_ruby\1.8\;..\..\..\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\1.8\" /> </options> </microsoft.scripting> </configuration> -- Posted via http://www.ruby-forum.com/.