Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10106 closed bug (invalid)

#!executable doesn't work as expected.

Reported by: bbjimmy Owned by: bonefish
Priority: normal Milestone: R1
Component: System/runtime_loader Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

To reproduce: download yab : http://haikuware.com/directory/view-details/development/editors/unofficial-yab-17-fixed-paste-error-of-textedit

Install yab on hrev43218 by placing the Version 0.1.2/bin/Haiku-alpha4/yab binary in /boot/home/config/non-packaged/bin

open the the example program: Version 0.1.2/Programs/Examples/Calc.yab with styled edit.

Change the first line to #!yab and save.

Set the executable bits: right click, Get info, Permissions, check the executable boxes.

double-click on the file.

yab shows in the deskbar for an instant.

Using the same steps on r1a4.1, the program will launch if yab is in /boot/home/config/bin.

The program launches from the command line, but not by double-clicking the script as expected.

Change History (15)

comment:1 by anevilyak, 11 years ago

Any particular reason for using that old of a Haiku version? That's 3000 revisions ago.

comment:2 by anevilyak, 11 years ago

Resolution: invalid
Status: newclosed

That has nothing to do with the shebang or runtime loader, yabasic.h hardcodes its library path to "/boot/home/config/lib/yab" at line 117, and consequently will fail if the files it's looking for aren't in that exact location, which is frankly broken.

comment:3 by bbjimmy, 11 years ago

that is a typo, it is 46218

comment:4 by bbjimmy, 11 years ago

Resolution: invalid
Status: closedreopened

That has nothing to do with the shebang or runtime loader, yabasic.h hardcodes its library path to "/boot/home/config/lib/yab" at line 117, and consequently will fail if the files it's looking for aren't in that exact location, which is frankly broken.

This has nothing to do with running the scripts, only with compiling them into a binary. This is not being done to run the script. /boot/home/config/lib/yab was a mistake, but it is for aditional yab scripts to be included at compile time. this scroipt, Calc.yab has no librarys. It is stand alone.

Last edited 11 years ago by bbjimmy (previous) (diff)

comment:5 by anevilyak, 11 years ago

Resolution: invalid
Status: reopenedclosed

No, it's part of the yab interpreter itself, the fact that you see yab in Deskbar means it was in fact found and started, it's simply then failing because it later fails to find other things because of bad assumptions about paths.

comment:6 by bbjimmy, 11 years ago

Then why does the script run from the command line?

in reply to:  6 comment:7 by augiedoggie, 11 years ago

Replying to bbjimmy:

Then why does the script run from the command line?

It actually doesn't run properly from the command line unless you're in the directory with the script in it. The problem seems to be that yab can't handle directory names with spaces in it. If you rename the default directory or move the script somewhere else then it works. You can see the error when trying to run the script with the full path....

cpr@sluggo:~# ~/Desktop/Version\ 0.1.2/Programs/Examples/Calc.yab
---Error: could not open '/boot/home/Desktop/Version': No such file or directory

comment:8 by bbjimmy, 11 years ago

Thanks, by the way, for my yab version I am changing the library path to /boot/home/config/settings/yab ... this is where yab looks for included yab library script files if they are not in the working directory. I take it the settings directory will continue to be read/write in the future.

comment:9 by axeld, 11 years ago

Besides that settings are not the place for libraries or script files, the only thing you know for sure is that B_USER_SETTINGS_DIRECTORY will always be writable for you. While there are no immediate plans to actually change the path now, once there will be multi user support in Haiku, it will pretty damn sure.

The point is: there is a future proof API, and that one should be used. Any assumptions outside of it may or may not fail in the future. Following that API will make sure your software will continue to run on future versions of Haiku.

comment:10 by bbjimmy, 11 years ago

The point is: there is a future proof API, and that one should be used. Any assumptions outside of it may or may not fail in the future. Following that API will make sure your software will continue to run on future versions of Haiku.

And just what is that? Where can we tell users of yab they can place their library scripts and have yab locate them? yab librarys are user data, but they need to be protected from casual file actions that may accidentilly move or delete them. This is why the original yab devs chose the /boot/home/config tree,

comment:11 by pulkomandy, 11 years ago

yab should use find_directory to locate the files. The API was already available in BeOS and allows changes to the filesystem mapping to work fine. http://www.haiku-os.org/legacy-docs/bebook/BDirectory.html#find_directory

Whatever directory you decide to use (be it lib, add-ons, or apps), there is a set of constants for it. yab should look in the different possible places (system, common and user) and grab files from all 3. In Haiku we removed COMMON and added non-packaged constants instead. These can be used the same, and if done right, yab will be able to locate both scripts and libs coming from the non-packaged folder, or from hpkg files, and manage to run them all.

comment:12 by bbjimmy, 11 years ago

YAB has no find_directory() command. The only tool available to a YAB developer is to use:

dir$=system$("finddir B_COMMON_BIN_DIRECTORY")

The finddir command line tool has to be fixed to fix YAB developed programs.

To think that all developers use c or c++, or can just go and add a c/c++ system call to their programming language is making a BIG assumption.

Last edited 11 years ago by bbjimmy (previous) (diff)

comment:13 by pulkomandy, 11 years ago

Sorry if I don't understand correctly, but I think you are mixing several different issues here.

1) Running YAB as a script interpreter: this was fixed by using #!yab without path 2) Having yab locate its library/script files: this is where find_directory should be used 3) YAB scripts/programs using finddir because there is no find_directory: I agree we should do something there, we already have an ML thread about that and I'll send another message to it. Ideally, the command should be added to yab so future programs can make use of it in a safer way.

My comment was about step 2: yab should be modified to handle that.

I'm not familiar with yab at all, so if I get something wrong, please explain more clearly and with an example (I think I should be able to read some code snippets).

comment:14 by bbjimmy, 11 years ago

I modified yab at compile time to look for the library scripts in B_USER_SETTINGS_DIRECTORY/yab by changing a line in the makefile:

HAIKUOPT = -DHAIKU -DLIBRARY_PATH=\"finddir B_USER_SETTINGS_DIRECTORY/yab\"

and the header file now looks like this:

#ifndef LIBRARY_PATH #define LIBRARY_PATH "/boot/home/config/settings/yab" #endif

But, this is not the right way to do it.

I don't know enough about c++ to implement find_directory in the source code for yab. There is a tutorial on adding a command to yab on http://besly.de ... http://www.besly.de/index.html?/menu/search/archiv/dev/yab_tutorial_eng.html, but It is over my head.

I use yab, I didn't program it.

comment:15 by pulkomandy, 11 years ago

Hi, In hrev46258 I added support for B_COMMON_ to finddir (the command line app) again. They will point to /boot/system/non-packaged, now. I hope you don't mind the directory name change too much.

Note: See TracTickets for help on using tickets.