Error during DevContainer setup

Hi,

I am going through the steps for setting up DevContainers for CM development and am hitting an issue when re-opening the scaffold project in the DevContainer. A “task” prompt is eventually opened and it tries to execute “cmf login sync”, which results in the error below. I don’t understand where I’ve gone wrong. Any advice would be appreciated.

Executing task: cmf login sync

User successfully logged in

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Exception: Failed to store credentials into CMF Auth File /home/vscode/.cmf-auth.json
System.UnauthorizedAccessException: Access to the path ‘/home/vscode/.cmf-auth.json’ is denied.
System.IO.IOException: Permission denied
at void Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, string path, bool isDirError)
at SafeFileHandle Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions
options, long preallocationSize, UnixFileMode openPermissions, out long fileLength, out UnixFileMode filePermissions, bool failForSymlink, out
bool wasSymlink, Func<ErrorInfo, OpenFlags, string, Exception> createOpenException)
at SafeFileHandle System.IO.File.OpenHandle(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long
preallocationSize)
at async Task System.IO.File.WriteToFileAsync(string path, FileMode mode, string contents, Encoding encoding, CancellationToken cancellationToken)
at async Task Cmf.CLI.Core.Services.RepositoryAuthStore.WriteFile(CmfAuthFile authFile) in /home/runner/work/cli/cli/core/Services/
RepositoryAuthStore.cs:81
at async Task Cmf.CLI.Core.Services.RepositoryAuthStore.SaveInternal(IList credentials, bool sync) in
/home/runner/work/cli/cli/core/Services/RepositoryAuthStore.cs:446
at async Task Cmf.CLI.Core.Services.RepositoryAuthStore.SaveInternal(IList credentials, bool sync) in
/home/runner/work/cli/cli/core/Services/RepositoryAuthStore.cs:450
at async Task Cmf.CLI.Core.Services.RepositoryAuthStore.Save(IList credentials, bool sync) in
/home/runner/work/cli/cli/core/Services/RepositoryAuthStore.cs:364
at async Task Cmf.CLI.Commands.SyncCommand.ExecuteAsync(RepositoryCredentialsType? repositoryType, string repository) in
/home/runner/work/cli/cli/cmf-cli/Commands/login/SyncCommand.cs:84
at void Cmf.CLI.Commands.SyncCommand.Execute(RepositoryCredentialsType? repositoryType, string repository) in
/home/runner/work/cli/cli/cmf-cli/Commands/login/SyncCommand.cs:58
at object System.RuntimeMethodHandle.InvokeMethod(object target, Void** arguments, Signature sig, bool isConstructor)
at object System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(object obj, Span copyOfArgs, BindingFlags invokeAttr)
at object System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(object obj, Span copyOfArgs, BindingFlags invokeAttr)
at object System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(object obj, BindingFlags invokeAttr, Binder binder, object parameters, CultureInfo culture)
at object System.Delegate.DynamicInvokeImpl(object args)
at async Task System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at void System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<b__0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<b__0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<b__0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<b__0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__18_0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<b__0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__5_0>d.MoveNext()
at void System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<b__0>d.MoveNext()

  • The terminal process “/bin/bash ‘-c’, ‘cmf login sync’” terminated with exit code: 255.
  • Terminal will be reused by tasks, press any key to close it.

Hi Ben,

It looks like a permission mismatch between your host machine and the DevContainer. The path /home/vscode/.cmf-auth.json inside the container is typically a mount point linked to a file in your local environment (likely your WSL profile).

Here are a few things to check to resolve the UnauthorizedAccessException:

Host File Permissions: Ensure the .cmf-auth.json file exists on your local machine and that your local user has full read/write permissions to it.

User Mapping (UID/GID): If you are running as root on your host machine, the vscode user inside the container may not have permission to modify the mounted file. You can test this by temporarily granting broader permissions to the file on your host (chmod 666 ~/.cmf-auth.json) to see if the error clears.

DevContainer Lifecycle Logs: Check the Remote-Containers output log in VS Code during the “Reopening in Container” process. Look for any warnings related to “Bind Mounts” or “Mounting failures.”

Pre-create the file: the mount fails if the file doesn’t exist yet on the host. Create an empty file on your host before launching the container.

Best regards,

João Moreira