#failed to load outer env file when trying to run `dagger init` in an empty directory

1 messages · Page 1 of 1 (latest)

next laurel
#

I'm trying to initialise a new module in an empty directory just as I have several times before, using dagger init, but for some reason I'm now getting the following error…

moduleSource(refString: ".", disableFindUp: true, allowNotExists: true, requireKind: LOCAL_SOURCE): ModuleSource! 0.0s ERROR
! load user defaults: failed to load outer env file from "../../../../../.env": select: select: lstat /.env: no such file or directory
╰╴▼ Host.file(path: "../../../../../.env"): File! 0.0s ERROR
  ! select: lstat /.env: no such file or directory
  ╰╴✘ Directory.file(path: ".env"): File! 0.0s ERROR
    ! lstat /.env: no such file or directory
Error: failed to check if module already exists: load user defaults: failed to load outer env file from "../../../../../.env": select: select: lstat /.env: no such file or directory

Any idea why this might be?

#

Sorry. I should have also said I'm pretty new to Dagger, so please don't assume much knowledge.

heavy field
#

@next laurel this might be a regression, sorry... could you give me steps to reproduce the issue?

next laurel
#

@heavy field Sorry. All I'm doing is running dagger init --sdk=php --name=ci, and it fails. Not much more to say, other than my version…

$ dagger version
dagger v0.19.2 (image://registry.dagger.io/engine:v0.19.2) darwin/arm64/v8

Can I access some form of logs to provide more context?

heavy field
#
  • Are you inside a git repository? If so, at what depth?

  • Are you inside another dagger module? (ie. is there already a dagger.json in a parent directory)

#
  • Does anything get created on the local directory? Or does it fail and not create anything?
#
  • Also just to confirm: does the dagger init actually fail (exit code non-zero), or does it succeed but print a weird error?
next laurel
#

Are you inside a git repository? If so, at what depth?

  • Yes, $gitRoot/dagger

Are you inside another dagger module? (ie. is there already a dagger.json in a parent directory)

  • No

Does anything get created on the local directory? Or does it fail and not create anything?

  • No. It's still empty.

Also just to confirm: does the dagger init actually fail (exit code non-zero), or does it succeed but print a weird error?

  • Exit code=1
#

@heavy field ☝️

heavy field
#

Thanks. Probably unrelated, but I recommend creating the module in the root of the git repo, instead of a dagger subdirectory 🙂

#

this way your dagger functions will be easily discoverable directly from anywhere in your repo (git clone MY_REPO; cd MY_REPO; dagger functions)

next laurel
#

@heavy field OK. This pattern has works fine in other repos, and I find it keeps the main repo files un-muddled from the supporting Dagger module files. So would you like me to raise a bug for this?

heavy field
heavy field
# next laurel <@488409085998530571> OK. This pattern has works fine in other repos, and I fin...

If you run dagger init in a non-empty directory (like your root) the generated files will be automatically be tucked away in a separate source directory. By default .dagger but you can change it with dagger init --source. the only file remaining at the root will be dagger.json, which is desirable for the discovery benefits, and also for cleaner context. If you set a default path to your directory arguments for example, the path will be relative to the module root

next laurel
next laurel
next laurel