aptly icon indicating copy to clipboard operation
aptly copied to clipboard

ERROR: unable to publish: stat None: no such file or directory

Open Vitexus opened this issue 2 years ago • 2 comments

Strange error when publish command is run using TMPDIR

Detailed Description

Publish command

aptly publish snapshot  -batch -component=backports,borrowed,main,spoje -distribution=focal focal-backports_2022-03-14 focal-borrowed_2022-03-14 focal-main_2022-03-14 focal-spoje_2022-03-14 focal-all-2022-03-14

Fail when run by ansible (with TMPDIR=~) When same command started by hand everything goes well:

jenkins@vyvojar:~$ aptly publish snapshot -component=backports,borrowed,main,spoje -distribution=focal focal-backports_2022-03-14 focal-borrowed_2022-03-14 focal-main_2022-03-14 focal-spoje_2022-03-14 focal-all-2022-03-14
Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag)
Loading packages...
Generating metadata files and linking package files...
Finalizing metadata files...
Signing file 'Release' with gpg, please enter your passphrase when prompted:
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:

Snapshots focal-backports_2022-03-14, focal-borrowed_2022-03-14, focal-main_2022-03-14, focal-spoje_2022-03-14 have been successfully published.
Please setup your webserver to serve directory '/var/lib/jenkins/workspace/RebuildDebRepo/public' with autoindexing.
Now you can add following line to apt sources:
  deb http://your-server/focal-all-2022-03-14/ focal backports borrowed main spoje
Don't forget to add your GPG key to apt with apt-key.

You can also use `aptly serve` to publish your repositories over HTTP quickly.

But ansible run fail with messages:

"stderr_lines": ["ERROR: unable to publish: stat None: no such file or directory"]
"stdout_lines": ["Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag)"]

Context

I thing, this is error.

Possible Implementation

substitute the '~' character in 'TMPDIR' variable to realpath of home directory

OR change message to:

ERROR: unable to publish: stat temporary directory None: no such file or directory

Your Environment

           "DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/222/bus'",
           "HOME='/var/lib/jenkins'",
            "IFS=' \t",
            "'",
            "LANG='cs_CZ.UTF-8'",
            "LC_ADDRESS='cs_CZ.UTF-8'",
            "LC_IDENTIFICATION='cs_CZ.UTF-8'",
            "LC_MEASUREMENT='cs_CZ.UTF-8'",
            "LC_MONETARY='cs_CZ.UTF-8'",
            "LC_NAME='cs_CZ.UTF-8'",
            "LC_NUMERIC='cs_CZ.UTF-8'",
            "LC_PAPER='cs_CZ.UTF-8'",
            "LC_TELEPHONE='cs_CZ.UTF-8'",
            "LC_TIME='cs_CZ.UTF-8'",
            "LOGNAME='jenkins'",
            "MAIL='/var/mail/jenkins'",
            "OPTIND='1'",
            "PATH='/usr/local/bin:/usr/bin:/bin:/usr/games'",
            "PPID='90706'",
            "PS1='$ '",
            "PS2='> '",
            "PS4='+ '",
            "PWD='/var/lib/jenkins'",
            "SHELL='/bin/bash'",
            "SHLVL='0'",
            "SSH_CLIENT='77.87.240.5 51804 22'",
            "SSH_CONNECTION='77.87.240.5 51804 77.87.240.104 22'",
            "SSH_TTY='/dev/pts/6'",
            "TERM='xterm-256color'",
            "USER='jenkins'",
            "TMPDIR"='~',
            "XDG_RUNTIME_DIR='/run/user/222'",
            "XDG_SESSION_CLASS='user'",
            "XDG_SESSION_ID='1416'",
            "XDG_SESSION_TYPE='tty'",
            "_='/bin/sh'"

Vitexus avatar Mar 14 '22 01:03 Vitexus

I ran into this problem as well, I let Ansible make sure that TMPDIR is set for my user running aptly commands, fully expanded. If you configure rootDir deviating from the default, e.g. to /opt/aptly, some temporary files end up in /opt/aptly/tmp, while others are written to TMPDIR - Setting TMPDIR to <rootDir>/tmp makes sure everything ephemeral ends up in a single place.

My wrapper (stupidly) ensures this state on every call.

r4co0n avatar Jun 29 '23 14:06 r4co0n

Please note that environment variables should contain expanded paths, in your sample, $TMPDIR should be /var/lib/jenkins, your $HOME, instead of ~.

And you probably do not want to use home as your temporary directory, but create some subdirectory, maybe /var/lib/jenkins/tmp. Or just set it to /tmp, which should already exist.

There are many applications not doing the expansions you are used to when using a shell.

r4co0n avatar Jun 29 '23 15:06 r4co0n