-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NativeLibs version conflict #187
Comments
Adding insult to injury, this version is listed as 0.0.3, when it's, in fact, newer than the published version of NativeLibs. |
There are two distributions in the ecosystem that provide
and
If you don't qualify, a simple If you want the other, you have qualify more, such as |
Generally we think of module resolution without any qualifier as taking the highest version available, but really its the highest version available from the first repo of
and since each one of those Technically zef could work-around this issue by first installing everything into a temporary repo but that is A) a pretty big workflow change and B) just creates a new impediance between already-installed modules and the temporary repo (since again, first $*REPO containing any version). The real way to fix this, as @CurtTilmes mentions, is to use a more qualified name when using modules. For instance DBIish could add an
to ensure it always uses the expected NativeLibs. |
Removing NativeLibs from DBIish and depending on the other package appears to work. https://github.com/raku-community-modules/DBIish/compare/rbt.nativelibs-dependency Tests pass on Linux for MySQL, MariaDB, SQLlite, and PostgreSQL. If someone could test Oracle or with Windows, then removing it from DBIish might be best. |
Some more context from 2016 -- salortiz/JsonC#2 (comment) |
All other things being equal, would it have helped if the NativeLibs module were in CPAN rather than the ecosystem? |
Nope. It’s just inevitable that people will need to qualify their use statements more and more as time goes on. |
Nick, I think @JJ is working on some module best practice stuff and your advice above sounds like something important to be in there. Some questions, please:
|
This is what @tbrowder is talking about Raku/problem-solving#72 |
It is not needed in this case. The comment is there to show how one could add the additional constraints based on META6.json if they wanted.
I don't understand this question |
I don't know if eliminating this version completely will do the trick.
There's a good amount of differences:
```
➜ NativeLibs git:(master) diff lib/NativeLibs.pm6
../DBIish/lib/NativeLibs.pm6
3,11c3,4
< use NativeCall;
< sub EXPORT(|) {
< my $exp = &trait_mod:<is>.candidates.first: { .signature ~~
:(Routine, :$native!) };
< Map.new(
< 'NativeCall' => NativeCall,
< '&trait_mod:<is>' => $exp.dispatcher
< )
< }
< unit module NativeLibs:auth<salortiz>:ver<0.0.7>;
---
unit module NativeLibs:auth<sortiz>:ver<0.0.8>;
use NativeCall :ALL;
30,31c23
< # This is an HLL clone of MoarVM's loadlib, freelib, et.al. ops.
< # not available in rakudo.
---
# Right now NC::cglobal unload loaded libraries too fast, so we need
our own loader
34,35c26
< my %Libraries;
< my \dyncall = $*VM.config<nativecall_backend> eq 'dyncall';
---
my \dyncall = $*VM.config<nativecall_backend> eq 'dyncall';
40,41c31,32
< sub dlerror(--> Str) is native { * } # For linux or darwin/OS
X
< sub GetLastError(--> uint32) is native('kernel32') { * } # On
Microsoft land
---
my sub dlerror(--> Str) is native { * } # For linux or
darwin/OS X
my sub GetLastError(--> uint32) is native('kernel32') { * } # On
Microsoft land
43c34,41
< is-win ?? ( dlerror() // '' ) !! "error({ GetLastError })";
---
given $*VM.config<osname>.lc {
when 'linux' | 'darwin' {
dlerror() // '';
}
when 'mswin32' | 'mingw' | 'msys' | 'cygwin' {
"error({ GetLastError })";
}
}
46,48c44,46
< sub dlLoadLibrary(Str --> DLLib) is native { * } # dyncall
< sub dlopen(Str, uint32 --> DLLib) is native { * } # libffi
< sub LoadLibraryA(Str --> DLLib) is native('kernel32') { * }
---
my sub dlLoadLibrary(Str --> DLLib) is native { * } # dyncall
my sub dlopen(Str, uint32 --> DLLib) is native { * } # libffi
my sub LoadLibraryA(Str --> DLLib) is native('kernel32') { * }
50c48
< is-win ?? LoadLibraryA($libname) !!
---
is-win ?? LoadLibraryA($libname) !!
60,81c58
< fail "Cannot load native library '$libname'";
< }
< }
<
< sub dlFindSymbol( DLLib, Str --> Pointer) is native { * } # dyncall
< sub dlsym( DLLib, Str --> Pointer) is native { * } # libffi
< sub GetProcAddress(DLLib, Str --> Pointer) is native('kernel32') { * }
< sub GetModuleHandleA( Str --> DLLib) is native('kernel32') { * }
< method symbol(::?CLASS $self: Str $symbol, Mu $want = Pointer) {
< my \c = \(
< $self.DEFINITE ?? $!library !!
< is-win ?? GetModuleHandleA(Str) !! DLLib,
< $symbol
< );
< my \ptr = (
< is-win ?? &GetProcAddress !! dyncall ?? &dlFindSymbol !!
&dlsym
< )(|c);
<
< if ptr && $want !=== Pointer {
< nativecast($want, ptr);
< } else {
< ptr
---
fail "Cannot load native library '$libname'" ~ self!dlerror();
85,88c62,63
< sub dlFreeLibrary(DLLib) is native { * }
< sub dlclose( DLLib) is native { * }
< sub FreeLibrary( DLLib --> int32) is native('kernel32') { * }
< method dispose(--> True) {
---
sub dlFreeLibrary(DLLib) is native { * };
method dispose {
90,91c65
< is-win ?? FreeLibrary($_) !!
< dyncall ?? dlFreeLibrary($_) !! dlclose($_);
---
dlFreeLibrary($_);
98c72
< method !test($try, $wks) {
---
method !test(Str() $try, $wks) {
102a77
return $wlibname unless $libname; # Nothing to test
104c79
< my $version = $_.defined ?? Version.new($_) !! Version;
---
my $ver = $_.defined ?? Version.new($_) !! Version;
106c81
< cannon-name($libname, $version), $wks;
---
cannon-name($libname, $ver), $wks;
111c86
< $wlibname //= self!test: "lib$libname.dll", $wks if is-win;
---
$wlibname //= self!test: "lib$libname.dll", $wks;
114d88
<
123c97
< #die "Cannot locate native library '$libname'"
---
# die "Cannot locate native library '$libname'"
129,156d102
<
< class Compile {
< has @.files;
< has $.name;
< has $.lib;
< has $.outdir;
<
< my $cfg = $*VM.config;
< submethod BUILD(:$!name!, :$!outdir, :@!files) {
< @!files.push: $!name unless @!files;
< $!lib = $*VM.platform-library-name($!name.IO);
< $_ .= subst(/\.c$/,'') for @!files;
< }
<
< method compile-file($file is copy) {
< my $CC = "$cfg<cc> -c $cfg<ccshared> $cfg<cflags>";
< my $c-line = join(' ', $CC, "$cfg<ccout>$file$cfg<obj>",
"$file.c");
< shell($c-line);
< }
<
< method compile-all {
< self.compile-file($_) for @!files;
< my $LD = "$cfg<ld> $cfg<ldshared> $cfg<ldflags> $cfg<ldlibs>";
< my $l-line = join(' ', $LD, "$cfg<ldout>$!lib", @!files.map(* ~
$cfg<obj>));
< shell($l-line);
< }
< }
<
161d106
…--
JJ
|
I think that for the time being the best way to solve the conflict is simply give it different names. |
Should I (or could I) as a module author publishing public modules use, as a general practice, your recommendation from above and generalize it, e.g.,
unless we have a special need to be more specific. Wouldn't that take care of the current problem even if it is using more constraints? |
Generally yes, that is what most people want. Note though that on windows this only works on releases after 2020.01 -- rakudo/rakudo@13c5d04 |
Great! I'll try to start doing that. Thanks. |
Is this resolved sufficiently? Can we close it? |
I think so, yes.
|
The And the only reason for not removing it from When the external (grow-up) So, @JJ 's ec857b4 commit is a really bad idea. I think that removing from |
@salortiz it's simply locking a specific version; @ugexe's idea of using the distribution version is very probably a better idea. I didn't want to remove a large chunk of code (and introducing another dependency on the process). I mean, at the end of the day, using the same name in two different (although related) pieces of code is bound to create name clashes. I'll reopen anyway and see if we can come together to a best solution (or, even better, PR) |
The diff you posted on Jun 2 shows that there are no real changes. That's all extra features in the real distribution, so it is totally fine to remove it from DBIish and add the dependency, IMO. |
This removes the built in NativeLibs:auth<sortiz>:ver<0.0.8> and adds a dependency on the one distributed separately as per discussion in #187.
This reverts commit ec857b4. By bumping the version above the other NativeLibs package, zef is installing DBIish to meet a dependency requirement on that file which probably isn't what is intended by 3rd parties. This will be followed up by using the external NativeLibs package.
This removes the built in NativeLibs:auth<sortiz>:ver<0.0.8> and adds a dependency on the one distributed separately as per discussion in #187. Removal of :auth will be done when (if?) zef stops picking up older DBIish versions for a NativeLibs dependency.
Local version of NativeLibs is 0.0.3, while external version is 0.0.7. This might lead to zef trying to look for it as a dependency. Or something, I'm not really sure what. At any rate, this leads to this error. I'm not sure of how to solve this. Probably having a single one, and listing it as a reference, is much better.
The text was updated successfully, but these errors were encountered: