OpenStreetMap

Fixing JOSM Launch Error

Posted by alexkemp on 7 July 2022 in English. Last updated on 8 July 2022.

I tried to launch JOSM for the first time in a little while & got the error:

failed to execute josm-latest no such file or directory

It had worked fine the last time I used it & had been continuously updated every since.

Searching for the Fix

An internet search did not reveal anyone reporting the same error, but did point me towards the GitHub site (more on that later, with the eventual fix at bottom of this diary post). Searching the computer did not help much, but it did reveal the .desktop menu file:

$ locate josm-latest
/etc/default/josm-latest
/usr/bin/josm-latest
/usr/share/applications/org.openstreetmap.josm-latest.desktop
/usr/share/josm-latest/josm-latest.jar

My local .desktop menu file is identical to the GitHub-code latest .desktop file. I tried running the exec-line in that file from a console (I work under Devuan, which is a Linux distribution):

$ josm-latest %U
bash: /usr/bin/josm-latest: /usr/bin/bash: bad interpreter: No such file or directory

Here is the reason why:

$ file /etc/default/josm-latest
/etc/default/josm-latest: ASCII text
$ cat /etc/default/josm-latest
# Options to pass to java when starting JOSM.
# Uncomment the JAVA_OPTS lines to enable their use by /usr/bin/josm-latest

# Increase usable memory
#JAVA_OPTS="${JAVA_OPTS} -Xmx2048m"

# Enable OpenGL pipeline (2D graphic accelerators)
#JAVA_OPTS="${JAVA_OPTS} -Dsun.java2d.opengl=True"
$ file /usr/bin/josm-latest
/usr/bin/josm-latest: Bourne-Again shell script, ASCII text executable
$ head -1 /usr/bin/josm-latest
#!/usr/bin/bash
$ la /usr/bin/bash
ls: cannot access '/usr/bin/bash': No such file or directory
$ which bash
/bin/bash

(translation): Neither josm-latest provided within the latest JOSM is fit for purpose:

  • The first (in /etc/default) is a set of commented-out lines.
  • The 2nd (in /etc/default) is a script file intended to load JOSM, but the SHEBANG line (first in the script) does NOT point at the BASH executable.
  • The %U parameter is never taken into consideration within the script

The JOSM on GitHub README gave a different exec line than the josm-latest.desktop:

github README:

https://github.com/JOSM/josm/blob/master/README:

type “java -jar josm-latest.jar” to launch. If this does not work, try to set your JAVA_HOME variable to the java executable location (the root location, not the bin).

It still did not work:

# (/usr/share/josm-latest/josm-latest.jar)
$ java -jar josm-latest.jar
Error: Unable to access jarfile josm-latest.jar
$ echo $PATH
~/.local/bin:/usr/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

The GitHub README is talking about errors in locating JAVA but that is not the problem. The system cannot find josm-latest.jar, and that is the problem. The following works:

$ cat /usr/share/applications/org.openstreetmap.josm-latest.desktop
[Desktop Entry]
Type=Application
Version=1.0
Name=JOSM (latest snapshot)
…
# 2022-07-07 next line always throws "No such file or directory"; replaced by line following
# Exec=josm-latest %U
Exec=java -jar /usr/share/josm-latest/josm-latest.jar
…

Discussion

Comment from vorpalblade on 8 July 2022 at 23:41

This should be fixed in r18512. (The #!/usr/bin/bash has been changed to something a bit more universal). A new stable (r18513) has been released.

One thing I can say is that no one ran into this problem with josm-latest for the past 20 days or so (that is when the offending change was first committed), until after I tagged a new josm-tested version.

I’m sorry about this – it worked fine on my system when I was testing (note: new debian installs have merged /bin into /usr by default – why did debian have to have this half-done half-not-done state for usr merge?).

The reason for the change was to work around an issue where the behavior between /bin/bash and /usr/bin/bash on the shebang line differed, with #!/bin/bash having improper behavior.

Comment from vorpalblade on 8 July 2022 at 23:48

Note: the %U is documented in the .desktop specification as

%U: A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.

In the script, the $@ is all positional arguments.

Can you please update to r18513 or later, and let me know if it doesn’t work?

Comment from alexkemp on 9 July 2022 at 01:12

$ locate josm-latest
…
/usr/share/josm-latest/josm-1.5.svn18513.jar
$ cat /usr/share/applications/org.openstreetmap.josm-latest.desktop
# (my changes have been reversed)
$ head -1 /usr/bin/josm-latest
#!/usr/bin/env bash

So OK, let’s see if it works now.

It does! (although I did not use it in anger, since I really need to get some sleep).

Well done, and thank you.

PS I’ve never tried this, but would setting the SHEBANG line dynamically using *which bash” actually work?

Anyway, many thanks for the fix.

Log in to leave a comment