Giter Club home page Giter Club logo

Comments (10)

alexander-smolyakov avatar alexander-smolyakov commented on August 31, 2024 1

@bluesherpa, glad to hear that you were able to find the source of the issue.

I see two possible solutions:

  1. Disabling Auto CrLf.
  2. 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.

samruddhikhandale avatar samruddhikhandale commented on August 31, 2024

@alexander-smolyakov Can you help investigate this issue? thanks!

from templates.

bluesherpa avatar bluesherpa commented on August 31, 2024

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.

bluesherpa avatar bluesherpa commented on August 31, 2024

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.

samruddhikhandale avatar samruddhikhandale commented on August 31, 2024

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.

bluesherpa avatar bluesherpa commented on August 31, 2024

It sounds like the line endings in install-mariadb.sh need to be fixed, not the README, if that helps.

from templates.

bluesherpa avatar bluesherpa commented on August 31, 2024

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.

alexander-smolyakov avatar alexander-smolyakov commented on August 31, 2024

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:

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.

bluesherpa avatar bluesherpa commented on August 31, 2024

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:

  1. Disabling Auto CrLf.
  2. Using dos2unix after copying the file into the container.

Which approach do you recommend?

from templates.

bluesherpa avatar bluesherpa commented on August 31, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.