steve8x8 / geotoad

Geocaching query tool written in Ruby
https://buymeacoffee.com/steve8x8
Other
28 stars 8 forks source link

undefined method `realpath' for File:Class (NoMethodError) #303

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I try to launch geotoad using:
ruby geotoad.rb
I have trie it with 3.19.2, 3.20.0 and 3.20.1 on Xubuntu 12.04 using the both 
the latest ruby and ruby1.8.
Always i get right when calling th ementioned command:
geotoad-3.19.2/geotoad.rb:7: undefined method `realpath' for File:Class 
(NoMethodError)

Original issue reported on code.google.com by ctietg...@gmail.com on 29 May 2014 at 8:26

GoogleCodeExporter commented 9 years ago
Ruby 1.8 has been deprecated, you should at least use 1.9.1.

Apparently Ubuntu's ruby is somewhat different from everyone else's:

$ irb
irb(main):001:0> File.methods
=> [:directory?, :exist?, :exists?, :readable?, :readable_real?, 
:world_readable?, :writable?, :writable_real?, :world_writable?, :executable?, 
:executable_real?, :file?, :zero?, :size?, :size, :owned?, :grpowned?, :pipe?, 
:symlink?, :socket?, :blockdev?, :chardev?, :setuid?, :setgid?, :sticky?, 
:identical?, :stat, :lstat, :ftype, :atime, :mtime, :ctime, :utime, :chmod, 
:chown, :lchmod, :lchown, :link, :symlink, :readlink, :unlink, :delete, 
:rename, :umask, :truncate, :expand_path, :absolute_path, :realpath, 
:realdirpath, :basename, :dirname, :extname, :path, :split, :join, :fnmatch, 
:fnmatch?, :new, :open, :sysopen, :for_fd, :popen, :foreach, :readlines, :read, 
:binread, :write, :binwrite, :select, :pipe, :try_convert, :copy_stream, 
:allocate, :superclass, :freeze, :===, :==, :<=>, :<, :<=, :>, :>=, :to_s, 
:included_modules, :include?, :name, :ancestors, :instance_methods, 
:public_instance_methods, :protected_instance_methods, 
:private_instance_methods, :constants, :const_get, :const_set, :const_defined?, 
:const_missing, :class_variables, :remove_class_variable, :class_variable_get, 
:class_variable_set, :class_variable_defined?, :public_constant, 
:private_constant, :module_exec, :class_exec, :module_eval, :class_eval, 
:method_defined?, :public_method_defined?, :private_method_defined?, 
:protected_method_defined?, :public_class_method, :private_class_method, 
:autoload, :autoload?, :instance_method, :public_instance_method, :nil?, :=~, 
:!~, :eql?, :hash, :class, :singleton_class, :clone, :dup, :initialize_dup, 
:initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, 
:frozen?, :inspect, :methods, :singleton_methods, :protected_methods, 
:private_methods, :public_methods, :instance_variables, :instance_variable_get, 
:instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, 
:is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, 
:display, :method, :public_method, :define_singleton_method, :object_id, 
:to_enum, :enum_for, :equal?, :!, :!=, :instance_eval, :instance_exec, 
:__send__, :__id__]
$ irb -v
irb 0.9.6(09/06/30)
$ ruby -v
ruby 2.0.0p299 (2013-08-29) [i686-linux]

Can you run "irb" and check the methods available for the File class?

Original comment by Steve8x8 on 2 Jun 2014 at 7:08

GoogleCodeExporter commented 9 years ago
Adding a line "require 'pathname'" to each of the four affected source files 
should fix the issue even for Ubuntu users. Can someone please confirm?

Original comment by Steve8x8 on 13 Jun 2014 at 3:19

GoogleCodeExporter commented 9 years ago
Nobody?

Original comment by Steve8x8 on 25 Jun 2014 at 5:32

GoogleCodeExporter commented 9 years ago
In a different app that suffered from this, I also had to swizzle things around 
a bit:

-$path = File.dirname(File.realpath(__FILE__))
+$path = File.dirname(Pathname.new(__FILE__).realpath)

Original comment by daniel.r...@gmail.com on 3 Jul 2014 at 6:02

GoogleCodeExporter commented 9 years ago
Closing after 6 months of inactivity.

Original comment by Steve8x8 on 23 Jan 2015 at 10:20