Comments (10)
@bluesherpa, glad to hear that you were able to find the source of the issue.
I see two possible solutions:
- Disabling Auto CrLf.
- Using dos2unix after copying the file into the container.
Which approach do you recommend?
It depends on the use case. If you are working on multiple repositories, and some contain projects intended to work on different platforms, it's better to keep AutoCrLF enabled. Otherwise, you can disable AutoCrLF.
from templates.
@alexander-smolyakov Can you help investigate this issue? thanks!
from templates.
I figured out part of the problem. This second error appears to be a problem with line endings in the file install-mariadb.sh.
Here is the error:
failed to solve: executor failed running [/bin/sh -c chmod +x /tmp/install-mariadb.sh && /tmp/install-mariadb.sh && rm -f /tmp/install-mariadb.sh]: exit code: 127
To confirm this, I manually ran install-mariadb.sh from inside of the container and got an unknown command error "/bin/bash^M"
I did this by commenting out this line in the Dockerfile:
RUN chmod +x /tmp/install-mariadb.sh && /tmp/install-mariadb.sh && rm -f /tmp/install-mariadb.sh
I then performed the following steps starting in the .devcontainer folder:
docker build -t test -f Dockerfile .
docker run -it --rm --name=test test bash
cd /tmp
./install-mariadb.sh
got the error invalid command "/bin/bash^M"
sudo apt install dos2unix
dos2unix install-mariadb.sh
./install-mariadb.sh
the installation was successful
I exited the container, deleted the container and image, ran dos2unix on the install-mariadb.sh file from outside of the container, then opened the project folder in Visual Studio Code, telling it to open the folder in a new container. Everything worked this time.
This was using code generated from inside of Visual Studio Code by going to F1 > Dev Containers > Create New Container > C++ and MariaDB.
Let me know if you have any questions about these steps/instructions.
I'll try again using the newest version of the cpp_mariadb template from GitHub.
from templates.
I see that https://github.com/devcontainers/templates/blob/main/src/cpp-mariadb/.devcontainer/Dockerfile has:
FROM mcr.microsoft.com/devcontainers/cpp:0-${templateOption:imageVariant}
How would I use this template inside of Visual Studio Code so that the placeholder is replaced with the correct platform?
from templates.
I see, looks like you have copied over the contents from this repository? Can you follow the instructions mentioned in #113 (comment) Thanks!
I'll shortly open a PR to update the README to provide these instructions.
from templates.
It sounds like the line endings in install-mariadb.sh need to be fixed, not the README, if that helps.
from templates.
I looked at the steps in #113 and confirmed that the it pulls from the templates/src/cpp-mariadb folder of the repo. It looks like the line endings issue is all that needs to be addressed.
from templates.
Hey @bluesherpa, I didn't manage to reproduce your case. As I can see, the end-of-line for all scripts is set to LF
, so it should work fine with Docker. Could you please double-check your system configuration? Sometimes IDE or Git could perform end-of-line conversion based on their configuration.
Related docs:
- https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace (Formatting and Whitespace);
- https://code.visualstudio.com/docs/getstarted/settings.
VS code default settings:
// The default end of line character.
// - \n: LF
// - \r\n: CRLF
// - auto: Uses operating system specific end of line character.
"files.eol": "auto",
from templates.
Hello @alexander-smolyakov, thank you for your assistance. I have confirmed that when cloning with Tortoise Git, the line endings are automatically converted to Windows format. This is due to the fact that AutoCrLF is enabled by default when using OpenSSH/git. Consequently, the file that was copied into the container has Windows-style line endings, which is causing the error.
I see two possible solutions:
- Disabling Auto CrLf.
- Using dos2unix after copying the file into the container.
Which approach do you recommend?
from templates.
@alexander-smolyakov Sounds good. I'll go with option 2 for now resolving the issue. Thanks again, I appreciate your help with this.
from templates.
Related Issues (20)
- ruby-rails-postgres devcontainer has no internet access
- Hi π HOT 1
- dotnet template should include a volume mount for nuget package caching HOT 1
- include C# Dev Kit in dotnet template HOT 3
- Pin PostgreSQL version in `*-postgres` templates HOT 2
- javascript-node-mongo not building the container HOT 2
- Could not connect to mariaDB with imageVariant default HOT 1
- Docs about templates usage and behavior HOT 4
- Is there a way to `publish` template as image?
- typescript-node npm scripts error access HOT 1
- Stuck in "Replacing imageVariant with ..." step HOT 7
- I am a greener. Just ask a simple question about the toolchain in the container. HOT 1
- C+
- Active HOT 2
- postCreateCommand Permission denied HOT 2
- SSH key sharing works only for 0-20 HOT 4
- rust-postgres template does not work HOT 2
- how to properly use apt-get for dev container? HOT 1
- PowerShell Dev Container not published to Microsoft Artifact Registry HOT 1
- "Permission Denied Error when Running Non-Root Podman Development Container: mkdir: cannot create directory β/rootβ" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templates.