ruby tk -- how do you get it working?

7

7stud --

Tim said:
One small point I meant to bring up earlier - when I've written scripts
like this in the past, I always have the script *move* the files to a
temporary location rather than deleting them directly. That way I can
inspect everything and delete them by hand if everything checks out
ok...

Maybe that's overly paranoid but having a script delete something
important by mistake really sucks... :)

Delete 1500 files by hand?
 
7

7stud --

7stud said:
Delete 1500 files by hand?

Ah. I think I get what you mean now. Instead of deleting the files,
you would have the program collect all the files in a new directory.
Then after running the program if the original ruby install works
correctly, you know you can safely run another program to delete all the
files in the new directory.

One problem I see with that is: if your original ruby install failed to
work correctly, you won't have any idea how to put everything back
together again. In order to know how to put all the files back in their
previous locations, you would have to do something like create a file in
the new directory which lists the original path of the each file and the
new path. Then you could create a program that reads that file and
moves all the files back to their previous directories. Or is there an
easier way?
 
T

Tim Ferrell

7stud said:
Ah. I think I get what you mean now. Instead of deleting the files,
you would have the program collect all the files in a new directory.
Then after running the program if the original ruby install works
correctly, you know you can safely run another program to delete all the
files in the new directory.

Exactly ... stage the deletes somewhere like ${HOME}/temp_delete and, if
everything looks ok do a simple rm -rf ...
One problem I see with that is: if your original ruby install failed to
work correctly, you won't have any idea how to put everything back
together again. In order to know how to put all the files back in their
previous locations, you would have to do something like create a file in
the new directory which lists the original path of the each file and the
new path. Then you could create a program that reads that file and
moves all the files back to their previous directories. Or is there an
easier way?

There is an easier way :) Preserve the path underneath the temp root...
something like:


def delete_to_stage(file)
destdir = File.join(TEMPROOT, File.dirname(file))
FileUtils::mkdir_p(destdir)
FileUtils::mv(file, destdir)
end

Then you know exactly where things go back if need be...

Cheers,
Tim
 
7

7stud --

Tim said:
def delete_to_stage(file)
destdir = File.join(TEMPROOT, File.dirname(file))
FileUtils::mkdir_p(destdir)
FileUtils::mv(file, destdir)
end

Thanks. I was just playing around with mkdir_p(I was actually using the
alias mkpath). I tested it out on my test directory structure(from
above), moving the files from those directories into another
directory--keeping their paths intact--and it worked nicely. One thing
I discovered: join() doesn't work in this case. You are trying to join
something like:

/users/me/Test + /users/me/2testing/dir2/test2.txt

and join just puts a '/' between them producing:

/users/me/Test //users/me/2testing/dir2/test2.txt
 
T

Tim Ferrell

7stud said:
One thing
I discovered: join() doesn't work in this case. You are trying to join
something like:

/users/me/Test + /users/me/2testing/dir2/test2.txt

and join just puts a '/' between them producing:

/users/me/Test //users/me/2testing/dir2/test2.txt

I'm not seeing that here...

Tim@macbook: ~ => irb
I am on the latest ruby though (1.8.6-p111) so behavior might have
changed since 1.8.2...

Cheers,
Tim
 
L

Louis-philippe L-p

mmm, that thread is soo long... and doesn't seem to solve the firs
issue... does it?
anyway...

For me, it started to work when I did the following:
Are you building Ruby from source? If so, try going to the ext/tk
directory and running

ruby extconf.rb

If that seems to work, continue with make and make install.
If it does not seem to be finding the Tcl/Tk libraries, try reading the
README.tcltklib file in that directory.

it gave me an error message saying to recompile with --enable-pthread
option. which I did... solved my ruby tk trouble.

so, what you need to de is :

* get ruby source
* ./configure --enable-pthread
* make
* make test
* sudo make install
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top