Problem to copy files with tmpfs

Hi guys, I have a question. Recently when I tested my package manager write in Crystal , I noticed if the files my package manager try to move are mounted in tmpfs like this:

tmpfs                   /tmp            tmpfs           rw,nosuid,noatime,nodev,mode=1777       0       0
tmpfs                   /var/tmp        tmpfs           rw,nosuid,noatime,nodev,mode=1777       0       0

It fail with the error that the file can’t be found . Why ?

Hard to tell, can you reduce the example to something we can run?

I try to.

This is the error I get:

[!] Failed to move /tmp/ism/builtsoftwares/KdeSoftwares-Main/Dolphin/23.8.0/usr/lib/libdolphinvcs.so.5 to /usr/lib/libdolphinvcs.so.5
[!] 
Error opening file with mode 'r': '/tmp/ism/builtsoftwares/KdeSoftwares-Main/Dolphin/23.8.0/usr/lib/libdolphinvcs.so.5': No such file or directory

And the function called from my software:

def runSystemCommand(command : String, path = Ism.settings.installByChroot ? "/" : Ism.settings.rootPath, environment = Hash(String, String).new, environmentFilePath = String.new) : Process::Status
            environmentCommand = String.new

            if environmentFilePath != ""
                environmentCommand = "source \"#{environmentFilePath}\" && "
            end

            environment.keys.each do |key|
                environmentCommand += " #{key}=\"#{environment[key]}\""
            end

            Ism.recordSystemCall(command, path, environment)

            if Ism.settings.installByChroot
                chrootCommand = <<-CODE
                #!/bin/bash
                cd #{path} && #{environmentCommand} #{command}
                CODE

                process = runChrootTasks(chrootCommand)
            else
                process = Process.run(  command,
                                        output: :inherit,
                                        error: :inherit,
                                        shell: true,
                                        chdir: (path == "" ? nil : path),
                                        env: environment)
            end

            return process
        end

def moveFile(path : String, newPath : String)
            requestedCommands = "mv #{path} #{newPath}"

            process = runSystemCommand(requestedCommands)

            if !process.success?
                Ism.notifyOfRunSystemCommandError(requestedCommands)
                Ism.exitProgram
            end
        end

Hi,

Your question seems more related to Linux systems than to Crystal, which might be why you’re not getting many replies. I wasn’t sure either, so I asked ChatGPT for some insight. I know it can be a bit annoying when people share AI-generated answers, so I hope you don’t mind. Here’s what it suggested:

It might be due to the chroot environment affecting access to /tmp or /var/tmp. Since chroot environments can’t access files outside their own directory structure, the files in /tmp might not be available inside the chroot. You might want to check if those directories are properly mounted within the chroot.

Hope this helps!

Trivia
It’s easy to download a Discourse discussion in Markdown text format. You can easily download the Markdown text for this page from the following URL.

https://forum.crystal-lang.org/raw/7185

2 Likes

@kojix2 That is an interesting bit of trivia. Might be interesting enough to be its own topic and not so buried.

It’s interesting, but actually this installation didn’t use the chroot mode. :sweat_smile: