Command-line invocation on Mac OSX partially broken

Bug #181639 reported by blahedo on 2008-01-09
84
This bug affects 11 people
Affects Status Importance Assigned to Milestone
Inkscape
Low
Unassigned

Bug Description

Although one can invoke inkscape from the command line on the Mac build, it (apparently) requires that you give the full pathname, or else it can't find support files it needs. Specifically, if I create a symlink in /usr/local/bin that links to /Applications/Inkscape.app/Contents/Resources/bin/inkscape , running inkscape --help complains that pango, gtk-2.0, and inkscape-bin can't be found. If I create further links in /usr/local/bin and /usr/local/etc to resolve those issues, I get a dylib failure looking for a file in /Users/mjwybrow—who I assume is one of you:
dyld: Library not loaded: /Users/mjwybrow/ws-fat/lib/libgtkmm-2.4.1.dylib
  Referenced from: /usr/local/bin/inkscape-bin
  Reason: image not found
Trace/BPT trap

This is in v0.45.1 on macosx v10.4.11 on a G5.

Related branches

Ryan Lerch (ryanlerch) on 2008-01-23
Changed in inkscape:
status: New → Incomplete
blahedo (blahedo) wrote :

Ok, so you marked it as incomplete; could you maybe say what further information you're looking for? I've already told you the version, the OS, and instructions on how to repro the bug....

JiHO (jiho) wrote :

Sorry, this is because none of us reacted to the bug report. I confirmed it so it will stay now.

Regarding your issue, this is indeed to be expected. /Applications/Inkscape.app/Contents/Resources/bin/inkscape is a shell script which runs inkscape and sets part of the environment (but not all) so it won't behave as an Inkscape executable (because it isn't) and it won't run smoothly (because the environment is not completely set, this is our fault). This is a problem to debug Inkscape in particular.

There's no real solution to this issue unfortunately. All OS X applications I know that provide a command line interface, do it by building a custom executable, statically linked to the app-specific libraries (i.e. all libraries for Inkscape, since it does not rely on OS X provided libraries). Then one can symlink this executable to /usr/local/bin. If we did this for Inkscape, the executable would be enormous and adding it to the app bundle will nearly double its size.

Once Inkscape is native (i.e. the executable in /Applications/Inkscape.app/Contents/MacOS/Inkscape is actually the inkscape binary), we may find a way to write a custom script that sets everything correctly and passed command line arguments to this binary. Before that, I guess that the launcher would need a major overhaul to run correctly. Volunteers are welcome ;)

So, now for the solutions, in the meantime:
- if you just want to run "inkscape whatever.svg" to open a document from the command line you can:
     . associate Inkscape to svg documents and run "open whatever.svg"
     . define an alias in .bashrc which says: alias inkscape="open -a '/Applications/Inkscape.app'" (NB: see this hint on how to make this work automatically for all apps http://www.macosxhints.com/article.php?story=2004032210304035)
- if you want to run Inkscape from the command line, as you would do on Linux, to batch convert svgs to pngs for exemple, I would advise you to install Inkscape from either Fink or MacPorts (I know MacPorts works and will be updated) and you will have a regular executable in /sw/bin or /opt/local/bin

Hope that helps,
JiHO

Changed in inkscape:
importance: Undecided → Wishlist
status: Incomplete → Confirmed
tags: added: osx
tags: added: cli
su_v (suv-lp) on 2013-03-11
tags: added: packaging
Keenan Brock (keenan-m) wrote :

to fix this, I modified /Applications/Inkscape.app/Contents/Resources/bin/inkscape to read:

CMD="$(readlink $0 || echo $0)"
CWD="`(cd \"\`dirname \\\"$CMD\\\"\`\"; pwd -P)`"

This properly resolves the symbolic link. Then the rest of this script works great.

If this is not clear, let me know and I'll try and learn bizarre / create an account.

Thanks for the great software.

su_v (suv-lp) wrote :

Diff for 0.9x (which has seen a minor update for osx packaging) attached (there are no further bug-fix releases of the current stable 0.48.x branch planned).

Source file in current trunk <lp:inkscape>:
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/13839/packaging/macosx/Resources/bin/inkscape#L18

Note that resolving symbolic links to the launcher script won't address / overcome the other main weakness of the current osxapp-enabled builds: files on the command line still require absolute path names (see FIXME comment [1]).

--
[1] http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/13839/packaging/macosx/Resources/bin/inkscape#L25

su_v (suv-lp) wrote :

@Keenan Brock: thanks for the tip - I have committed the diff to this branch for now:
https://code.launchpad.net/~inkscape.dev/inkscape/packaging-macosx-update
(gathering latest changes for osx-packaging there, to be merged into trunk (and hopefully to the release branch for 0.91 as well))

su_v (suv-lp) wrote :

Partial fix committed to
- trunk <lp:inkscape> in r13856
- stable release branch <lp:inkscape/0.91.x> in r13704

Changed in inkscape:
importance: Wishlist → Low
status: Confirmed → Triaged
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers