Dotnet: application prints "realpath(): Invalid argument" when compiled on windows and run on linux

Created on 13 May 2016  路  24Comments  路  Source: microsoft/dotnet

Repro steps

  1. Install dotnet sdk. version 1.0.0-preview1-002702
  2. dotnet new
  3. dotnet build (do this in windows).
  4. copy the folder over to Linux.
  5. dotnet app.dll (without rebuilding)

Application prints "realpath(): Invalid argument" immediately when it is launched.
Does not reproduce when application is built on Linux and run on Windows.

Most helpful comment

Same issue on vs 2019 stable and and vs 2019 preview

Microsoft Visual Studio Community 2019 Preview
Version 16.3.0 Preview 3.0
VisualStudio.16.Preview/16.3.0-pre.3.0+29230.61
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Community

OS Name: Microsoft Windows 10 Pro Insider Preview
OS Version: 10.0.18932 N/A Build 18932

>> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.801
 Commit:    c404ee777a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18932
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.801\

Host (useful for support):
  Version: 3.0.0-preview9-19423-09
  Commit:  2be172345a

.NET Core SDKs installed:
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
  3.0.100-preview9-014004 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview9.19424.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview9-19423-09 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview9-19423-09 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

All 24 comments

scratch my previous repro steps.

If the dotnet app is run on a share it prints out "realpath(): Invalid argument" as soon as it gets launched.

Please re-activate if this is still an issue.

Have same issue when launch a debug session in VS 2017, that holds a webapp in a docker container.

Using this Dockerfile in VS 2017

FROM microsoft/aspnetcore ARG source WORKDIR /app EXPOSE 80 COPY ${source:-obj/Docker/publish} . ENTRYPOINT ["dotnet", "Expense.UI.dll"]

You are missing "dotnet publish" in your example above.

Try the examples documented here: https://github.com/dotnet/dotnet-docker-samples/tree/master/dotnetapp-prod

I see that the samples are still RC4-focussed. We'll fix that.

This is still an issue if you try start debug a docker package that is built using Visual Studio 2017. You are out of control for det commands to run there so the issue arise.

You may only use the Microsoft .NET Core Debugger (vsdbg) with Visual Studio
Code, Visual Studio or Visual Studio for Mac software to help you develop and
test your applications.

realpath(): Invalid argument

@kendrahavens Can you look at this?

@dozer75 Sorry, I feel I'm still lacking some context to reproduce this with the VS 2017 Docker scenario. Is this specific to dotnet sdk version 1.0.0-preview1-002702? What container OS and version are you using?

Local:
$ dotnet --info
.NET Command Line Tools (2.1.0-preview1-006632)
Product Information:
Version: 2.1.0-preview1-006632
Commit SHA-1 hash: 5c67b11d62
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.0-preview1-006632\
Microsoft .NET Core Shared Framework Host
Version : 2.1.0-preview2-25520-02
Build : 632aa6827e4ffba5f3cb1ec9fb105100c85f7f23

Docker version 17.06.0-ce, build 02c1d87 (Linux containers)
In dockerfile I have: FROM microsoft/aspnetcore:1.1.2

Build on Windows :)

@kendrahavens this happens when the application is volume mapped. By default VS 2017 Docker scenario volume maps the target application. AFAIK it doesn't break any scenarios.

Thank you @andreipet and @rajkumar42 for the extra info.

Just to clarify the repro steps are:

  1. Create/build a project in Visual Studio and add Docker support.
  2. Navigate to the same project in a file share from a Linux machine with Docker installed.
  3. Try to docker build from the command line.
  4. Fails with the realpath(): Invalid argument error because the Docker compose file tries to volume mount.

Is this accurate?

It is like @rajkumar42 said. It is related to the fact that I use the app/assembly from a mapped directory.
Please see: https://github.com/andreipet/docker_realpath
The DockerMessage project was created with Visual Studio 2017 from the asp.net core web app template, empty and with docker support. The meaningfull message appears.
I also created a simpler ConsoleApp with all the easy stuff inside. Please run .sh.
I also receive the message: realpath(): Invalid argument

I've also run into this using the standard ASP.NET Core 2.0 Web API project template using Visual Studio 2017 Professional 15.3.0 This really makes the entire Docker tooling for Visual Studio 2017 useless.

Here is the SDK version installed on my machine:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

The Docker file is looking for microsoft/aspnetcore:2.0 and pulled image id 0bc7246be73f to my machine.

If I then docker exec -it /bin/bash into the container and go to /app/bin/Debug/netcoreapp2.0/ and try to run dotnet MyApp.dll the error is repeatable.

realpath(): Invalid argument
realpath(): Invalid argument
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::replace: __pos (which is 18446744073709551613) > this->size() (which is 9)
Aborted

The dotnet --info from within the container is:

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

I just tried this. I no longer see the exact issues you see. The app doesn't start, but it fails because it is trying to launch with the same port as the running app. If I reset the ASPNETCORE_URLS environment variable to another value, it does work. That said, new port is not exported out of the Docker container, so it is inaccessible. Does that helps?

//cc @glennc

Any more thoughts / questions?

I'm still seeing this exact same issue in the latest version of Visual Studio 2017. It's a problem mainly because it prevents debugging in Visual Studio Code, which boinks cross-platform development (we have developers on Mac and Windows.)

Steps to reproduce this are as follows:

cd \git
mkdir docker-problems
cd docker-problems
dotnet new sln

Open .sln in Visual Studio 2017
Add New Project, Choose ASP.NET Core Web Application
Choose Empty, DO NOT check Enable Docker Support, select OK
Right-click WebApplication1, add Docker support, choose Linux, select OK
Build All (CTRL+SHIFT+B)

*At this point, docker ps will list a webapplication1:dev image, command is tail -f /dev/null

docker exec -it f93f427ef4dc /bin/bash
inside image#: dotnet bin/Debug/netcoreapp2.0/WebApplication1.dll

realpath(): Invalid argument
realpath(): Invalid argument
realpath(): Invalid argument
Hosting environment: Development
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
dotnet --info (on host)
.NET Command Line Tools (2.1.3)

Product Information:
 Version:            2.1.3
 Commit SHA-1 hash:  a0ca411ca5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.3\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.4
  Build    : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff
docker version (on host)
Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:40:09 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:45:38 2017
 OS/Arch:      linux/amd64
 Experimental: true 
- IDE INFO -

Microsoft Visual Studio Enterprise 2017 
Version 15.5.2
VisualStudio.15.Release/15.5.2+27130.2010
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Enterprise

Visual Basic 2017   00369-90250-47930-AA672
Microsoft Visual Basic 2017

Visual C# 2017   00369-90250-47930-AA672
Microsoft Visual C# 2017

Visual F# 4.1   00369-90250-47930-AA672
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.10.01106.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.31125.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.51007.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.31106.0
Azure App Service Tools v3.0.0

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JetBrains ReSharper Ultimate 2017.3.1    Build 111.0.20171221.145902
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright 漏 2018 JetBrains, Inc.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.51120.3

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager   4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61710.120
Microsoft SQL Server Data Tools

TypeScript Tools   15.5.11025.1
TypeScript Tools for Microsoft Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Hi,

I am on Windows 10 64bit, with the latest Visual Studio 2017 community installed. I got similar messages as @dozer75 did when trying to debug a .netcore console application with Docker support. Here is the complete output:

You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
realpath(): Invalid argument
realpath(): Invalid argument
realpath(): Invalid argument
realpath(): Invalid argument
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/app/bin/Debug/netcoreapp2.1/ConsoleApp1.dll'. Symbols loaded.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/System.Runtime.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/System.Console.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/System.Threading.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/System.Runtime.Extensions.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/System.Text.Encoding.Extensions.dll'. Module was built without symbols.
Hello World!
The program '[181] dotnet' has exited with code 0 (0x0).
The program '' has exited with code 0 (0x0).

The application is the standard Hello Word template. Interestingly, despite this message, I seem to able to debug without any problem. So this message is very confusing.

Same thing here, trying to debug an app generated with dotnet new react -o my-app.

  • If I run on Visual Studio 2017, everything works fine.
  • If I try to dotnet build on windows (inside a mapped volume) and try to dotnet bin/Debug/netcoreapp2.0/myapp.dll inside the container, i got realpath(): Invalid argument that everyone is talking about
  • If I try to dotnet publish on windows and dotnet bin/Debug/netcoreapp2.0/publish/myapp.dll inside de container, it works, but then the webpack-hot-middleware stops working and I have to republish the app after each change on my front-end *.tsx files, it sucks (my ASPNETCORE_ENVIRONMENT already is "Development" inside the container too, it simply doesn't detect file changes in my *.tsx files).

I ran dotnet publish on windows and dotnet bin/Debug/netcoreapp2.0/publish/myapp.dll in windows too, by curiosity, and the webpack-hot-middleware worked.

If I use dotnet publish instead of dotnet build as a workaround for the realpath(): Invalid argument problem, I got stuck on this webpack-hot-middleware issue inside a docker container accessing mounted volumes.

In both cases (running on windows or inside a linux container) I got this output at the beginning:

info: Microsoft.AspNetCore.NodeServices[0]
      webpack built 980414333b72121e67be in 5303ms

But only on windows I get this output when I edit some *.tsx file and save it:

info: Microsoft.AspNetCore.NodeServices[0]
      webpack building...
info: Microsoft.AspNetCore.NodeServices[0]
      webpack built 03db5c538cc9603889a0 in 1052ms

Should I open another issue for this?

I am also having this issue. Only the message is annoying, is not crashing anything. VS2017 15.9.9

Also having this issue fter updating to 15.9.9

Same problem in VS 2019

I also have this issue in 2019

Same issue on vs 2019 stable and and vs 2019 preview

Microsoft Visual Studio Community 2019 Preview
Version 16.3.0 Preview 3.0
VisualStudio.16.Preview/16.3.0-pre.3.0+29230.61
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Community

OS Name: Microsoft Windows 10 Pro Insider Preview
OS Version: 10.0.18932 N/A Build 18932

>> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.801
 Commit:    c404ee777a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18932
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.801\

Host (useful for support):
  Version: 3.0.0-preview9-19423-09
  Commit:  2be172345a

.NET Core SDKs installed:
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
  3.0.100-preview9-014004 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview9.19424.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview9-19423-09 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview9-19423-09 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

This issue was moved to dotnet/sdk#14816

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FlsZen picture FlsZen  路  4Comments

keslerm picture keslerm  路  8Comments

khionu picture khionu  路  12Comments

petroemil picture petroemil  路  4Comments

glucaci picture glucaci  路  7Comments