containers / build

another build tool for container images (archived, see https://github.com/rkt/rkt/issues/4024)
Apache License 2.0
342 stars 80 forks source link

Difficulties with set-working-directory #280

Closed swerter closed 7 years ago

swerter commented 7 years ago

Hello I'm having difficulties with set-working-directory. It somehow does not seem to work (or I don't know how). Here my build script:

acbuild --debug begin ./alpine-edge.aci
acbuild --debug run mkdir /hello
acbuild --debug set-working-directory /hello/
acbuild --debug run pwd
acbuild --debug run touch abc
acbuild --debug run ls
acbuild --debug write --overwrite hello.aci

which results in the output:

Beginning build with ./alpine-edge.aci
Running: [mkdir /hello]
Setting working directory to /hello/
Running: [pwd]
/
Running: [touch abc]
Running: [ls]
abc      dev      hello    lib      media    proc     run      srv      tmp      var
bin      etc      home     linuxrc  mnt      root     sbin     sys      usr
Writing ACI to hello.aci
warning: exec command was never set.

So it seems the working directory is still / instead of /hello. Can anybody help me? Is this a bug or am I missing something? Thanks.

cgonyeo commented 7 years ago

Sorry about the delay, the set-working-directory command only impacts what rkt does, the run subcommand to acbuild doesn't use it. You can use the --working-dir flag to the run subcommand to choose a working directory.

On Fri, Dec 9, 2016 at 5:30 AM, swerter notifications@github.com wrote:

Hello I'm having difficulties with set-working-directory. It somehow does not seem to work (or I don't know how). Here my build script:

acbuild --debug begin ./alpine-edge.aci acbuild --debug run mkdir /hello acbuild --debug set-working-directory /hello/ acbuild --debug run pwd acbuild --debug run touch abc acbuild --debug run ls acbuild --debug write --overwrite hello.aci

which results in the output:

Beginning build with ./alpine-edge.aci Running: [mkdir /hello] Setting working directory to /hello/ Running: [pwd] / Running: [touch abc] Running: [ls] abc dev hello lib media proc run srv tmp var bin etc home linuxrc mnt root sbin sys usr Writing ACI to hello.aci warning: exec command was never set.

So it seems the working directory is still / instead of /hello. Can anybody help me? Is this a bug or am I missing something? Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/containers/build/issues/280, or mute the thread https://github.com/notifications/unsubscribe-auth/ACU49VozO23iDZH8qx64M8ICd0DDEzznks5rGS3bgaJpZM4LIys2 .

swerter commented 7 years ago

Thanks a lot for your help. How about adding a small comment into the run documentation?

cgonyeo commented 7 years ago

Oh yeah, that should definitely be mentioned there. I'll put together a PR.

On Thu, Dec 29, 2016 at 12:44 PM, swerter notifications@github.com wrote:

Thanks a lot for your help. How about adding a small comment into the run documentation?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/containers/build/issues/280#issuecomment-269666030, or mute the thread https://github.com/notifications/unsubscribe-auth/ACU49SdOPBGAFKt0RdOsO-wUpPvAkJitks5rM_GPgaJpZM4LIys2 .

nomasprime commented 7 years ago

@dgonyeo I was expecting this to work like a Dockerfile WORKDIR. Is there a workaround for this? Having to pass --working-dir to run every time is a bit of a pain.

cgonyeo commented 7 years ago

set-working-directory doesn't work like this by design. All it does it update a line in a json file that rkt looks at later. The --working-dir flag is the way to set the working directory for a given run command.