Modify the source of a locally pinned package

Hi,

Please bear with me, I’m new to all this.

I followed the instructions to download/install an ocaml package from Github.

I did opam pin add <package_name> <dot_git_uri>, so far so good.

I compiled the examples using jbuilder. It works. Great.

Now, I would like to modify the source. I added a simple printf statement and re-built the examples but it doesn’t seem to have had any effects.

From that, I deduced that I basically need to recompile my local sources because jbuilder won’t.

My question is therefore: how can I “re-install” using my locally modified sources?

I believe the section last example here, regarding opam source, will show you how to do what you want.

Does it? I tried opam upgrade <my_package> but it seems to take the remote github as a reference instead of the locally modified code.

When I run an upgrade it tells me that I’m already up-to-date with the remote repository.

What I want is to re-build / “update” based on the local non-committed, non-pushed changes I have made.

If you want opam to reflect your local changes then you can pin against your local copy with opam pin /path/to/local_lib

If the library you’re editing and project you’re using it from are both using jbuilder then you can also symlink the library from inside of your project and jbuilder will automatically use the locally copy. For a rough example, if you have local_lib cloned and edited here:

/path/to/local_lib

and your project using local_lib here:

/path/to/my_project

then you can create a symlink to /path/to/local_lib under my_project and jbuilder will use the linked version of local_lib:

my_project/local_lib is a symlink to /path/to/local_lib

It seems you pinned
opam to the remote repository.

    In order to pin this

package to your copy, do something like : opam pin add the_package_name . -k path

(-k path
is needed if your directory is indeed a modified git repository)

1 Like