Hello
You can try to change the format of the script
to be inside a block
$script = <<-SCRIPT
cd /home/vagrant/pep_code
git init
git config --global user.name \"Giacomo\"
git config --global user.email \"[redacted]\"
git add * && git commit -m \"fix\"
mkdir build && cd build
CC=clang CXX=clang++ cmake -DWITH_CASTOR=OFF ..
ninja
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
On Thu, Jun 29, 2023 at 6:46 PM Giacomo Tommaso Petrucci <
[email protected]> wrote:
> Thank you for your answers. Yes, this is a little inconvenient but doable.
>
> Regards,
>
> Giacomo Tommaso Petrucci
>
> Il giorno giovedì 29 giugno 2023 alle 17:52:28 UTC+2 [email protected] ha
> scritto:
>
>> If neither one is an option you have to put multiple commands together
>> like cd /home/path1/subpath && ninja
>>
>> On Thursday, June 29, 2023 at 11:50:05 AM UTC-4 [email protected] wrote:
>>
>>> Jim is correct.
>>>
>>> You typically would want to run the command from the root with the full
>>> path e.g. ./home/vagrant/pep_code/build/ninja (if ninja is a script).
>>>
>>> If ninja is an app, you would do something like ninja <full path to
>>> file> e.g. ninja /home/vagrant/pep_code/build/<build_file>
>>>
>>> On Thursday, June 29, 2023 at 11:06:20 AM UTC-4 Jim McGinness wrote:
>>>
>>>> Each shell provisioning line runs as its own process. Directory changes
>>>> do not persist from one line to the next. You will need to gather your
>>>> individual lines into an actual script to get the result you want. For more
>>>> info, see
>>>>
>>>> https://developer.hashicorp.com/vagrant/docs/provisioning/shell
>>>>
>>>> -- jmcg
>>>>
>>>> On Thu, Jun 29, 2023 at 9:51 AM Giacomo Tommaso Petrucci <
>>>> [email protected]> wrote:
>>>>
>>>>> Greetings,
>>>>>
>>>>> I wrote the following Vagrantfile:
>>>>>
>>>>> Vagrant.configure("2") do |config|
>>>>> config.vm.box = "ubuntu/jammy64"
>>>>> config.vm.synced_folder "pep_code", "/home/vagrant/pep_code"
>>>>>
>>>>> # Update and install dependencies
>>>>> config.vm.provision "shell", inline: "echo Updating..."
>>>>> config.vm.provision "shell", inline: "sudo apt-get update && sudo
>>>>> apt-get -y upgrade"
>>>>> config.vm.provision "shell", inline: "sudo apt-get -y install clang
>>>>> ninja-build golang golang-goprotobuf-dev ccache distcc git cmake valgrind
>>>>> libboost-all-dev zlib1g-dev libbz2-dev libsqlite3-dev libcurl4-openssl-dev
>>>>> curl libpam0g-dev libssl-dev libreadline-dev patch vim flex qtbase5-dev
>>>>> qtdeclarative5-dev qttools5-dev qttools5-dev-tools libunwind-dev libc6-dev
>>>>> libc6-dev-i386 software-properties-common gcc-multilib"
>>>>> config.vm.provision "file", source: "pep_code", destination:
>>>>> "/home/vagrant/pep_code"
>>>>> config.vm.provision "shell", inline: "cd /home/vagrant/pep_code"
>>>>> config.vm.provision "shell", inline: "git init"
>>>>> config.vm.provision "shell", inline: "git config --global user.name
>>>>> \"Giacomo\""
>>>>> config.vm.provision "shell", inline: "git config --global user.email
>>>>> \"[redacted]\""
>>>>> config.vm.provision "shell", inline: "git add * && git commit -m
>>>>> \"fix\""
>>>>> config.vm.provision "shell", inline: "mkdir build && cd build"
>>>>> config.vm.provision "shell", inline: "CC=clang CXX=clang++ cmake
>>>>> -DWITH_CASTOR=OFF .."
>>>>> config.vm.provision "shell", inline: "ninja"
>>>>> end
>>>>>
>>>>> It fails while provisioning with the following message:
>>>>>
>>>>> default: CMake Error: The source directory "/home" does not appear to
>>>>> contain CMakeLists.txt.
>>>>> default: Specify --help for usage, or press the help button on the
>>>>> CMake GUI.
>>>>> The SSH command responded with a non-zero exit status. Vagrant
>>>>> assumes that this means the command failed. The output for this command
>>>>> should be in the log above. Please read the output to determine what
>>>>> went wrong.
>>>>>
>>>>>
>>>>> I was expecting the lines
>>>>>
>>>>> config.vm.provision "shell", inline: "cd /home/vagrant/pep_code"
>>>>>
>>>>> and
>>>>>
>>>>> config.vm.provision "shell", inline: "mkdir build && cd build"
>>>>>
>>>>> to change the working directory of the provisioning process, but this
>>>>> doesn't seem the case. Docker has an instruction for this, WORKDIR. Does
>>>>> Vagrant have something similar? A quick Google search didn't turn up
>>>>> anything.
>>>>> Thank you for your help,
>>>>>
>>>>> Giacomo Tommaso Petrucci
>>>>>
>>>>> --
>>>>> This mailing list is governed under the HashiCorp Community Guidelines
>>>>> - https://www.hashicorp.com/community-guidelines.html. Behavior in
>>>>> violation of those guidelines may result in your removal from this mailing
>>>>> list.
>>>>>
>>>>> GitHub Issues: https://github.com/hashicorp/vagrant/issues
>>>>> Discuss: https://discuss.hashicorp.com/c/vagrant/24
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Vagrant" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/vagrant-up/5ab0c5fe-f707-474a-9e3a-4720f31f331dn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/vagrant-up/5ab0c5fe-f707-474a-9e3a-4720f31f331dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/hashicorp/vagrant/issues
> Discuss: https://discuss.hashicorp.com/c/vagrant/24
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/e332ff1c-e4a4-47a9-b803-3fc7d3cec28cn%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/e332ff1c-e4a4-47a9-b803-3fc7d3cec28cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Alvaro
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/hashicorp/vagrant/issues
Discuss: https://discuss.hashicorp.com/c/vagrant/24
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/CAHqq0ex8s-8pOkmgppVkrLQa5o5n0%3DMtTSvqKzTmgbKqy5UqaA%40mail.gmail.com.