Technical question about update software itself

Hello, recently I’m thinking about a new feature for my software. I would like to make it able to change to an another version by itself (older or newer).

My software name is ISM. For example:
ism version switch Alpha-06012023

I would like if I type this on the terminal, my software compile itself.

Because I tried something like that, but it doesn’t work (I was almost sure about that). I just show you to get the idea about what I would like to do:

module ISM

    module Option

        class VersionSwitch < ISM::CommandLineOption

            def initialize
                super(  ISM::Default::Option::VersionSwitch::ShortText,

            def start
                if ARGV.size == 2+Ism.debugLevel
                    currentVersion = ARGV[2+Ism.debugLevel]

                    processResult =

                    process ="git",args: [  "describe",
                                                output: processResult)
                    previousVersion = processResult.to_s.strip
                    previousVersion = previousVersion.lchop(previousVersion[0..previousVersion.rindex("/")])

                    process ="git",args: [ "switch",
                    if !process.success?
                        process ="git",args: [ "switch",

                    process ="crystal",args: [ "build",

                    process ="git",args: [ "update-ref",



So how do you suggest can I proceed ?

No one ?

It seems to me that you are asking to write an application for you. I don’t see any particular problem you present, beside, “Here is my code, fix”.

You may:

  • Try to explain where your code is failing / what do you expect to work differently.
  • Show a minimal reproducible example of your problem.
  • Provide error messages

If you want an example of how some feature may be implemented, just look for it and read some code on GitHub/GitlLab/Bitbucket. Alternatively, you may ask GPT3, it tends to give a good start point for many applications.

Thank you for your message. Please read again, because it look like you didn’t understand my post.

I said:

So how do you suggest can I proceed ?

I ask for suggestions to do something, not to give me a code or a fix…

If I was to give my opinion on this, what I see you are trying to do is a pretty simple set of system calls for package management. I would suggest some scripting language, like Ruby or Bash, would be better suited for this kind of job. Other thing you may want to do is to use some task definition based language (rake, make) to setup your installation scripts.


Thank you, but it’s not the suggestion I ask for.
My project is already well advanced, and if I choose Crystal, it’s not for nothing.

Anyway, thank you but your suggestion doesn’t answer my question actually.

I am not suggesting you to change the language of your application. I just suggest it is generally better to solve the compilation and package management tasks with an actual task management system. You can then incorporate that script into your application. That will allow you to have a greater control over what and how you compile, against a raw inline system calls.

When you say “it doesn’t work”, what does that mean?

I think the general advice given here is:

  1. Make sure people that read your posts can copy and paste the code you include, run it and see exactly what you see, to be able to help you.
  2. Explain exactly what you want and why the current program isn’t doing what you want (what’s the actual output/behavior compared to the expected one?)

That might explain why nobody replied: they can’t because they don’t have enough information to do so.


Okay I got it :ok_hand:

I will explain more.

But first , to be clear, if you would like to run the code, you need to clone the entire repository. The implementation actually start to be big, and it will be very long to post all.

This is the entire project: GitHub - Fulgurance/ISM: Ingenius System Manager

So if you want to try the function for the help I asked for, first you just need to cd under the project and build it like this:

crystal build -o ism

Now just a few explanations before to try the function I made.

So what I tried to explain before is, I actually want my function able with git to switch to an another version of ISM , older or newer, and compile it.

So actually the code I linked is exactly the way I want, but it doesn’t work.

And just for a logic reason. Because the binary you execute can’t delete itself and overwrite with the new freshly compiled binary.

Just to summarize, when I type in the terminal (you can try it, the option actually exist):

./ism version switch Alpha-06012023

I would like this doing a git switch, build ISM with the detached focused tag or branch implementations, and replace the previous binary by the new generated binary.

If you want to check the implementation of this function, it’s located at ISM/Options/Version/Switch/

Let me know if you have any additionals questions. I hope this explanation was better.

I think this kind of thing is possible, because if for exemple you take emerge from the Gentoo project, emerge is able to update itself. It’s just I don’t know how to exactly proceed.

Since your application is running in your RAM, there should be no problem to recompile it and then relaunch the new compiled executable. You just need to remember to kill the previous process to free the memory.

Well, Portage is doing nothing more then downloading the source code of a package and then compiling it using a build script (so long you don’t install a binary file, as this is also an option). Build scripts are made the way that you don’t have to recompile the whole package, just the header files that have changed.

1 Like

I finally found the problem. It was super stupid. I just forgot to ignore the generated binary, because if git track it, it is unable to switch properly or detach