shoes / shoes3

a tiny graphical app kit for ruby
http://walkabout.mvmanila.com
Other
181 stars 19 forks source link

Cannot find cshoes for profiling? #419

Closed Dassadar closed 5 years ago

Dassadar commented 6 years ago

Hello, I need to profile my app, and found this article on the wiki: https://github.com/shoes/shoes3/wiki/Profiling It says to run cshoes to be able to profile. However I just have a shoes executable, and no cshoes. Can you please help? My system is Linux Mint, and I am using walkabout. Best regards, David

dredknight commented 6 years ago

Hello @Dassadar,

Cshoes is executable made for windows only.

Here is a workaround from the manual.

image

dredknight commented 6 years ago

@ccoupe,

Just downloaded 3.3.7 beta. Something is wrong with the mouse pointer and the manual (but may cover other aspects of the app as well).

Mouse selection point is at some offset.

Check out this screenshot image

My mouse points at "Run an app" entry but the actual selection is "Maintain Shoes". The same behavior observed in the manual as well.

Dassadar commented 6 years ago

Hello,

Then it means the profile command is equivalent to shoes -e... but -e option is not recognized?

David

Le 4 oct. 2018 à 20:02, dredknight notifications@github.com a écrit :

Hello @Dassadar,

Cshoes is executable made for windows only.

Here is a workaround from the manual.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ccoupe commented 6 years ago

-e requires the path to the script name to profile. For example, my ytm.rb in the ytm folder above my current directory. $ ~/.shoes/walkabout/shoes -e ../ytm/ytm.rb You can also start a profile from the Maintain Shoes screen.

ccoupe commented 6 years ago

@dredknight - that is the symptom of Shoes believing menus are enabled but they aren't in another part of Shoes. or vice versa.That looks like a Linux version, correct? Do you have a 'startup.yaml' file in the current directory ? If so, shoes might get confused. Or your theme/os uses a global menubar? instead of a per window menubar?

For explanation, when menus are enabled for a window then shoes has to account for the extra space of the menubar when calculating the mouse hit point. It's supposed to be per window but it's confused in your situation.

dredknight commented 5 years ago

@ccoupe the screenshots above are from windows installation of the 3.3.7. There is no startup.yaml in shoes directory or any of the subfolders.

ccoupe commented 5 years ago

It's possible that the beta you downloaded was compiled incorrectly. I've put a new exe (r3266) up at the usual place. I've checked it and it works here (for the issue mentioned)

dredknight commented 5 years ago

@ccoupe reinstalled r3266 but same behavior. It is globalwise - the manual or any custom made app has the same offset for the mouse.

Interesting enough debug console is working fine. Btw button size is a bit out of the black line border. image

ccoupe commented 5 years ago

Thats just odd. @dredknight ! Do you have two shoes installed? That should work but ...

You might try creating an startup.yaml in the same dir you launch cshoes.exe from. Example:

App_Name: Foobar
#Icon_Path: static/shoes-icon-blue.png
#Theme: XP 
Use_Menus: false 
Extra1: E:\exe-shoes\build-exe.rb

Toggling the Use_menus from false to true and setting the Appname so something other than Shoes. Don't worry about the Extra1 setting that's just a string your app can get if it wants. When Use_menus is set to true it should put a menubar on all windows and in theory mouse clicks should align better. Truly odd.

ccoupe commented 5 years ago

On other thought. Are there two windows, one hiding the other?

dredknight commented 5 years ago

@ccoupe to make it simpler here is a pic with all the stuff together.

image

I added the startup.yaml to Shoes directory and started the manual ( drew my mouse pointer as printscreen does not capture it). The issue still persists. :/

I do not have other Shoes installations.

Yesterday I installed 3.3.7 on this PC for the first time, then it was removed for the newer build you proposed.

Dassadar commented 5 years ago

Hello, -e still does not work despite the alias (not surprising, same result as shoes command): image I have managed to launch the Maintain Shoes screen... but then what should be done to launch a profile? image Thanks for your help, my slow application is desperately needing this ;-)

ccoupe commented 5 years ago

@Dassadar - I see a problem. Your Shoes is 3.3.1 (2+ years old!) A lot of things have been added since then, profiling being one of them. Shoes 3.3.6 is the latest and 3.3.7 is just around the corner. You'll need to update . Check the CHANGELOG file on git (code page) to see the changes and how they may affect your program.

ccoupe commented 5 years ago

@dredknight , one possibility I thought of since my last message was a theme problem but If this is a new PC then that's less likely. The startup.yaml file belongs in the directory you launch from - not inside shoes. From the terminal, $ cshoes.exe -c to start the cobbler. It always uses the menubar. Do you have them? Ctrl-I to get the info panel. (Test 1)

cd into a shoes program you've got or a test program. put the startup.yaml in there . Set Use_menu: true in that startup.yaml. Do a $ cshoes.exe -.rb - does the test app have a menubar ? (Test 2) Do the clicks go to the proper place in the app (Test 3)

dredknight commented 5 years ago

Ok so I put the startup.yaml file in the app directory. Open cmd and go to that directory and do all the tests as follows:

Test 1 - Cshoes -c When opened there is menu and it works great. All submenu elements on the window work without issue and there is no mouse problem. As soon as I select the manual from the cobler things get dirty and mouse offset appears.

CNTL+ I output

image

Startup.yaml is in skillwheel92 folder. This is where I start the cshoes from. This is where the app is started from too.

Test 2 - Launch the app with menu set to true. Menu appears.

Test 3 - Offset is present and clicks/hovers go to the offset location instead the place of the pointer. image

Expected behaviour image

ccoupe commented 5 years ago

Test 1 - Cshoes -c When opened there is menu and it works great. All submenu elements on the window work without issue and there is no mouse problem. As soon as I select the manual from the cobler things get dirty and mouse offset appears.

Why do problems have to be so hard? I tried this again on my Win 7 system and everything is fine. Are you on Win 10? My cobbler window has a blue title bar and a tiny Shoes icon. Your windows don't. cobbler-snap

I'm back to suspecting themes.

ccoupe commented 5 years ago

test 3 - you have a menu on your app, Clicks are misplaced. Try setting Use_Menus to 'false' and try you app. Still bad is my guess.

dredknight commented 5 years ago

Why do problems have to be so hard? I tried this again on my Win 7 system and everything is fine. Are you on Win 10? My cobbler window has a blue title bar and a tiny Shoes icon. Your windows don't.

@ccoupe I think you just solved half of the problem!!!

Yes I do use windows 10 and I was wondering for a day now why you decided to change the startup pane to look like the OSX (Mac?) one. May be 3.3.7 messes some visual or config stuff from OSX because it does not recognize windows 10 (sounds unbelievable but as I do not know the code just guessing)?

test 3 - you have a menu on your app, Clicks are misplaced. Try setting Use_Menus to 'false' and try you app. Still bad is my guess.

Menu is gone but offset still exists.

ccoupe commented 5 years ago

One thing that beta uses is a much newer version of the Gtk3 libraries. Speculating: perhaps newer gtk3 and win10 changed the reporting x,y of clicks from window relative to panel relative or vice verse. I've build a new shoes 3.3.7 for windows with the older libraries used in shoes 3.3.6, download at the usual beta place . Date will be Oct 9, 2018 r(number) may not change. Give it a try.

Dassadar commented 5 years ago

Hello, I updated to 3.3.6. I launched with -e : image Then I got this screen: image I remained on the first graphical option, then clicked on Start Profile... but nothing happened: I cannot see my app launching. Any idea please? Regards, David

ccoupe commented 5 years ago

Yeah, something does seem broken. I get an app launch but an error message when ending the profile. So two problems, counting yours. I don't like that error message you have about world writable /usr but that's not likely to be the problem. As always, check the console/log page for errors. It might give you a clue. The profiler is written in Ruby so you examine it in ~/.shoes/walkabout/lib/profiler.rb

Dassadar commented 5 years ago

If it can help I can provide my full code directory as it is a very good example to see if profiler is working (10s to load a complex army list).

I could not see other errors in the console than the screenshot previously sent.

Le 10.10.2018 09:03, Cecil Coupe a écrit :

Yeah, something does seem broken. I get an app launch but an error message when ending the profile. So two problems, counting yours. I don't like that error message you have about world writable /usr but that's not likely to be the problem. As always, check the console/log page for errors. It might give you a clue. The profiler is written in Ruby so you examine it in ~/.shoes/walkabout/lib/profiler.rb

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/shoes/shoes3/issues/419#issuecomment-428460967 [2] https://github.com/notifications/unsubscribe-auth/ALQ2sbsb4IqRUWoCX_tk7qc_1ohOepcuks5ujZvHgaJpZM4XHBmj

dredknight commented 5 years ago

@ccoupe works fine! No offsets whatsoever.

ccoupe commented 5 years ago

@dredknight - great news! Thanks for reporting. @Dassadar - I spoke too soon. The profiler works fine - it can't work with apps that use the url/visit paradigm which is what I forgot and tried. Profiling adds to the runtime, perhaps significantly so If it's slow to launch it will be slower when being profiled. Patience, check the console for exceptions.

IMO, performance problems are almost always IO based, particularly if databases are used, then Memory (lack of, garbage collection). Profiling won't tell you much about those issues that you didn't already suspect. Use some of the existing linux tools to watch what happening with the app. Is it saturating the cpu, memory or IO? Then profiling might help narrow that down. It's a black art if you don't know the app and if you do know the app you probably have a good guess at what's wrong.

Dassadar commented 5 years ago

I retried and left it for 10mn whereas the first screen is not doing much.

Same thing... nothing happens when I click start profile :(

And I am not using url/visit normally.

Le 10.10.2018 22:53, Cecil Coupe a écrit :

@dredknight [1] - great news! Thanks for reporting. @Dassadar [2] - I spoke too soon. The profiler works fine - it can't work with apps that use the url/visit paradigm which is what I forgot and tried. Profiling adds to the runtime, perhaps significantly so If it's slow to launch it will be slower when being profiled. Patience, check the console for exceptions.

IMO, performance problems are almost always IO based, particularly if databases are used, then Memory (lack of, garbage collection). Profiling won't tell you much about those issues that you didn't already suspect. Use some of the existing linux tools to watch what happening with the app. Is it saturating the cpu, memory or IO? Then profiling might help narrow that down. It's a black art if you don't know the app and if you do know the app you probably have a good guess at what's wrong.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [3], or mute the thread [4].

Links:

[1] https://github.com/dredknight [2] https://github.com/Dassadar [3] https://github.com/shoes/shoes3/issues/419#issuecomment-428727809 [4] https://github.com/notifications/unsubscribe-auth/ALQ2sRPwcNGL5y5LXvdTBprblsC9SHnvks5ujl44gaJpZM4XHBmj

ccoupe commented 5 years ago

after-start That's after the start profiling button is push - the app comes up. I do what ever the app is supposed to do and then press the end profiling button and that window switches to : after-stop

Dassadar commented 5 years ago

The app does not come up on my side ...

Le 11 octobre 2018 08:05:47 GMT+02:00, Cecil Coupe notifications@github.com a écrit :

after-start That's after the start profiling button is push - the app comes up. I do what ever the app is supposed to do and then press the end profiling button and that window switches to : after-stop

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes3/issues/419#issuecomment-428831742

-- Envoyé de mon appareil Android avec K-9 Mail. Veuillez excuser ma brièveté.

ccoupe commented 5 years ago

Things you can try. Try a known app $ ~/.shoes/walkabout/shoes -e ~/.shoes/walkabout/samples/simple/chipmunk.rb IS THERE ANYTHING in the console, Alt-/
Perhaps it doesn't like being launched in that directory. Move up one level if using the command line. Perhaps it doesn't like spaces in the path name.

Dassadar commented 5 years ago

The app example is working: I can see the report, however there is nothing in the console.

No change if launched from upper level (no app is launched)

No change if launched from a path without space.

Le 11.10.2018 08:57, Cecil Coupe a écrit :

Things you can try. Try a known app $ ~/.shoes/walkabout/shoes -e ~/.shoes/walkabout/samples/simple/chipmunk.rb IS THERE ANYTHING in the console, Alt-/ Perhaps it doesn't like being launched in that directory. Move up one level if using the command line. Perhaps it doesn't like spaces in the path name.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/shoes/shoes3/issues/419#issuecomment-428842647 [2] https://github.com/notifications/unsubscribe-auth/ALQ2sekgO-cIzwfyvEDzAnAo_d2YfYdgks5ujuvSgaJpZM4XHBmj

ccoupe commented 5 years ago

The app example is working: I can see the report, however there is nothing in the console.

Good. If it works with some apps (samples/simple/chipmunk.rb) w/o error message. It doesn't work on your app. This is good progress in finding the problem. Why doesn't it work with your app?

In ~/shoes/lwalkabout/lib/shoes/profiler.rb at lines 284-287 we have

        Dir.chdir(File.dirname(@file)) #do
          $shoes_profiler.start{ eval IO.read(File.basename(@file)).force_encoding("UTF-8"), TOPLEVEL_BINDING }
          load_end = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
        #end

Which expression is failing. File.dirname and File.basename would throw exceptions to the alt-/ console if they were failing. I'm going to speculate it's the force_encodeing. Any chance the script has Windows encoding ? I'd guess high. Try removing that . You'll have to edit the profiler.rb code so it looks like

         # $shoes_profiler.start{ eval IO.read(File.basename(@file)).force_encoding("UTF-8"), TOPLEVEL_BINDING }
          $shoes_profiler.start{ eval IO.read(File.basename(@file)), TOPLEVEL_BINDING }

Assuming that is the problem - how to fix your script. It really should be UTF-8 but some Windows editors don't do that.

Dassadar commented 5 years ago

no, still doesn't work :( If it can help... I deactivated the C calls, and the counts result in : cpu_time (1) and stop (0)

ccoupe commented 5 years ago

First we need to get your app/script loaded and on screen. That code snippet is pretty simple it's pretty much what shoes does from the splash screen -hmm, Can you just start shoes and 'open' your app from the splash screen?

Anyway, it's failing for your app but it's OK on the chipmunk example and its't not throwing exceptions for your app. It's narrowed down to a few lines of code. We can't forget that error message about /usr being writeable. You could write a little test program in another dir

Shoes.app do
   button "Launch" do
    Dir.chdir  "where the script is"
    scr =  IO.read('script.rb')
    eval scr, TOPLEVEL_BINDING
  end 
end

Something like that.

Dassadar commented 5 years ago

I created the test/test.rb directory

Code looking like this:

Shoes.app do button "Launch" do Dir.chdir "./.." scr = IO.read('tilea.shoes') eval scr end end

Here is the error I am getting when clicking on Launch:

Error in line 0 | 2018-10-12 12:55:04 +0000 cannot infer basepath test.rb:5:in eval' (eval):1:inblock (2 levels) in

' test.rb:5:in eval' test.rb:5:inblock (2 levels) in
'

Le 12.10.2018 00:50, Cecil Coupe a écrit :

First we need to get your app/script loaded and on screen. That code snippet is pretty simple it's pretty much what shoes does from the splash screen -hmm, Can you just start shoes and 'open' your app from the splash screen?

Anyway, it's failing for your app but it's OK on the chipmunk example and its't not throwing exceptions for your app. It's narrowed down to a few lines of code. We can't forget that error message about /usr being writeable. You could write a little test program in another dir

Shoes.app do button "Launch" do Dir.chdir "where the script is" scr = IO.read('script.rb') eval scr end end

Something like that.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/shoes/shoes3/issues/419#issuecomment-429146831 [2] https://github.com/notifications/unsubscribe-auth/ALQ2sTWblt5EKKV63vODkaaG2siOMlSlks5uj8sagaJpZM4XHBmj

ccoupe commented 5 years ago

You missed the edit I made a few seconds later ;-) eval scr, TOPLEVEL_BINDING

Just for testing, use an absolute path for the Dir.chdir - /home/dassadar/Insync/War......

Dassadar commented 5 years ago

With the extra argument, it works and my app is launching! It was not necessary to use an absolute path.

ccoupe commented 5 years ago

Now we need to debug the similar code in ~/.shoes/walkabout/lib/shoes/profiler.rb. I'm headed for sleep so I'll leave that to you.

Dassadar commented 5 years ago

I added some debugs:

      @trace_button = button 'Start Profile', state: (@file == nil ? "disabled": nil) do
        load_st = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
        $shoes_profiler.add_c_calls = @cc.checked?
        debug "file dir name #{File.dirname(@file)}"
        debug "file base name #{File.basename(@file)}"
    Dir.chdir(File.dirname(@file)) #do
          #$shoes_profiler.start{ eval IO.read(File.basename(@file)).force_encoding("UTF-8"), TOPLEVEL_BINDING }
         $shoes_profiler.start{ eval IO.read(File.basename(@file)), TOPLEVEL_BINDING }

          load_end = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
        #end
      end

Dir and base names are the expected ones, however I do not get why line 288 requires a configuration.rb which is not there? (this is the line $shoes_profiler.start{ eval IO.read(File.basename(@file)), TOPLEVEL_BINDING })

Debug in <unknown> line 0 | 2018-10-13 09:20:44 +0200
file dir name .

Debug in <unknown> line 0 | 2018-10-13 09:20:44 +0200
file base name tilea.shoes

Error in <unknown> line 0 | 2018-10-13 09:20:44 +0200
cannot load such file -- /home/dassadar/.shoes/walkabout/lib/shoes/code/configuration.rb
<main>:1:in `require_relative'
<main>:1:in `<main>'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:288:in `eval'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:288:in `block (4 levels) in index'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:190:in `start'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:288:in `block (3 levels) in index'
Dassadar commented 5 years ago

I really do not understand. I copied in hard the path and base file name, and used the exact same syntax as the test in the button section... and it does not work. Could it be associated to the fact that this is within a class and not directly under Shoes.app?

ccoupe commented 5 years ago

I'd separate the reading step from the eval call. I suspect you did that. Odds are something in your script is conflicting with profiler. It could be duplicate class names or top_level variable name. We try not to bleed them from profiler into the script being monitored but ....

Are you sure you don't have any lines that subclass 'Shoes` like this one of mine class YTMGUI < Shoes That is the url/visit paradigm that profiler won't work with.

Dassadar commented 5 years ago

That's probably very ugly, but all my classes do subclass Shoes. I think it was to be able to access app everywhere, no longer sure...

Le 13.10.2018 23:00, Cecil Coupe a écrit :

I'd separate the reading step from the eval call. I suspect you did that. Odds are something in your script is conflicting with profiler. It could be duplicate class names or top_level variable name. We try not to bleed them from profiler into the script being monitored but ....

Are you sure you don't have any lines that subclass 'Shoes` like this one of mine class YTMGUI < Shoes That is the url/visit paradigm that profiler won't work with.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/shoes/shoes3/issues/419#issuecomment-429574924 [2] https://github.com/notifications/unsubscribe-auth/ALQ2sfmpAq4Io0J00p41gMxVV737xH6-ks5uklSHgaJpZM4XHBmj

ccoupe commented 5 years ago

Yes, that would be an ugly amount of work. FWIW, you can get to app just about everywhere but it's not always what you might expect. It might be easier for you to write your own custom profiler that doesn't use the url/visit so it won't conflict with your app. Seems like a lot of work and little gain.

You can probably do what you need by instrumenting your app with calls to Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :microsecond)

Dassadar commented 5 years ago

What is the url/visit used for? If not useful for me, couldn't I remove it directly from the profiling script? If so, where is it?

For the other solution of instrumenting my app, do you mean something like setting debug prints everwhere? The app is too huge to do that...

Le 13.10.2018 23:14, Cecil Coupe a écrit :

Yes, that would be an ugly amount of work. FWIW, you can get to app just about everywhere but it's not always what you might expect. It might be easier for you to write your own custom profiler that doesn't use the url/visit so it won't conflict with your app. Seems like a lot of work and little gain.

You can probably do what you need by instrumenting your app with calls to Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :microsecond)

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/shoes/shoes3/issues/419#issuecomment-429575826 [2] https://github.com/notifications/unsubscribe-auth/ALQ2sX3Kl6VvUX_hfEywqBE22F9DuMggks5uklezgaJpZM4XHBmj

ccoupe commented 5 years ago

You define a 'url` for a each sublcass of Shoes (an App) and you switch to a new App with a visit call. It's pretty handy for some problems. Profiler has 3 or 4 of those to navigate. For instance between the graphical display of results or generating the text report version and back. Read the code and the manual and experiment profiling the chipmunk app until you see how the url/visit works. You need code to start/stop/collect and code to output the collection. I prefer the text report version which you can dump to the launch terminal (stdout/stderr). If you remove all the options in profiler then it's not that confusing.

Dassadar commented 5 years ago

Hello,

I've tried the other alternative: removing all direct inheritances from shoes to benefit from the standard profiler.

The only remaining mentions of Shoes are:

tilea.shoes:Shoes.app :width => 968, :height => 700, title: "Tunable Item List and Extended Army builder" do

code/menu.rb: @app.flow attach: Shoes::Window, height: 30 do

However the app still does not launch via the profiler? What can we look at please?

Regards,

David

Le 13.10.2018 23:33, Cecil Coupe a écrit :

You define a 'url` for a each sublcass of Shoes (an App) and you switch to a new App with a visit call. It's pretty handy for some problems. Profiler has 3 or 4 of those to navigate. For instance between the graphical display of results or generating the text report version and back. Read the code and the manual and experiment profiling the chipmunk app until you see how the url/visit works. You need code to start/stop/collect and code to output the collection. I prefer the text report version which you can dump to the launch terminal (stdout/stderr). If you remove all the options in profiler then it's not that confusing.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/shoes/shoes3/issues/419#issuecomment-429577021 [2] https://github.com/notifications/unsubscribe-auth/ALQ2sTYZ0LvKS-0t0AVDSKFvZJWAr5Txks5uklw6gaJpZM4XHBmj

Dassadar commented 5 years ago

Error from profiler.rb is the following when I am trying to launch the app outside of the @button section, would you have the configuration.rb file somewhere?

Error in <unknown> line 0 | 2018-10-14 08:38:04 +0200
cannot load such file -- /home/dassadar/.shoes/walkabout/lib/shoes/code/configuration.rb
<main>:1:in `require_relative'
<main>:1:in `<main>'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:282:in `eval'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:282:in `block (2 levels) in index'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:267:in `flow'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:267:in `block in index'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:220:in `stack'
/home/dassadar/.shoes/walkabout/lib/shoes/profiler.rb:220:in `index'
-e:1:in `call'
ccoupe commented 5 years ago

I'm not aware of any configuration.rb in any of shoes. Since it's thrown from the eval it may be something inside your code, mixed up/confused by something the profiler set before the eval. Shoes doesn't have a code/ subdirectory in lib/shoes.

see the manual for the 'app' method and the APPS constants. Is @app one of your variables? There's a wiki article about app but it might be more confusing than enlightening.

Dassadar commented 5 years ago

Hello, I understood the issue. My first line is require_relative './code/configuration.rb' Therefore ruby is looking for the file... but using the path from profiler.rb instead of tilea.rb! It looks like a known bug, what do you think? https://bugs.ruby-lang.org/issues/4487

ccoupe commented 5 years ago

require_relative './code/configuration.rb'

That works on Linux some of the time and almost never on Windows because Shoes can be installed in directories that the user doesn't have write access to. (It's possible to put an app in /usr/local/bin in Linux for example) . It's also a good reason for using ABS paths (which require_relative can use) If ruby sees a relative path, it's relative to Ruby's location which IS NOT the same as Shoes and NOT your app.

For requiring your ruby files, you want the path to your application, where ever it is installed. Shoes guarantees that Dir.getwd is that place at startup, so require_relative "#{Dir.getwd}/code/my_module.rb That's why profiler sets the cd before the eval(). For user writable config files you want something based on '#{ENV['HOME']}/.tilea' or on Windows ENV['APPDATA']

Cobbler's info screen displays some of the pre-existing paths.

cobbler
Dassadar commented 5 years ago

But my code is shared on different machines: how could I use an absolute path?

I haven’t underground how I can tell the eval to move to a different directory ?

Le 15 oct. 2018 à 20:40, Cecil Coupe notifications@github.com a écrit :

require_relative './code/configuration.rb'

That works on Linux some of the time and almost never on Windows because Shoes can be installed in directories that the user doesn't have write access to. (It's possible to put an app in /usr/local/bin in Linux for example) . It's also a good reason for using ABS paths (which require_relative can use) If ruby sees a relative path, it's relative to Ruby's location which IS NOT the same as Shoes and NOT your app.

For requiring your ruby files, you want the path to your application, where ever it is installed. Shoes guarantees that Dir.getwd is that place at startup, so require_relative "#{Dir.getwd}/code/my_module.rb That's why profiler sets the cd before the eval(). For user writable config files you want something based on '#{ENV['HOME']}/.tilea' or on Windows ENV['APPDATA']

Cobbler's info screen displays some of the pre-existing paths.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ccoupe commented 5 years ago

But my code is shared on different machines: how could I use an absolute path?

Ruby class Dir has many useful methods. Shoes has constants you can use. You compute them at the very beginning of your app or as needed. Try a little test program.

ccoupe@bronco:~$ pwd
/home/ccoupe
ccoupe@bronco:~$ more test-app/foo.rb 
$app_dir = Dir.getwd
Shoes.app do
  stack do
    para "Dir.getwd = #{$app_dir}"
    para "DIR = #{DIR}"
  end
end
ccoupe@bronco:~$ ~/.shoes/walkabout/shoes test-app/foo.rb 

Shoes set the working directory to the starting script location, not the directory you launched from. If you need to get to where Shoes is then use the DIR constant.