<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>10867</bug_id>
          
          <creation_ts>2017-01-01 21:38:39 +0000</creation_ts>
          <short_desc>bitbake with external layer fetcher fails to allow SRCPV to work</short_desc>
          <delta_ts>2024-06-13 15:07:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>OBSOLETE</resolution>
          
          
          <bug_file_loc>https://github.com/meta-rust/meta-rust/issues/136</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Doug Goldstein">cardoe</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>markus.lehtonen</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>yoctobugzilla</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>69424</commentid>
    <comment_count>0</comment_count>
    <who name="Doug Goldstein">cardoe</who>
    <bug_when>2017-01-01 21:38:39 +0000</bug_when>
    <thetext>I&apos;ve got a custom fetcher for Rust packages (which are called crates). It is very similar to the NPM fetcher. If I attempt to use SRCPV then bitbake fails when it hits one of my crate:// URLs. Which works just fine otherwise. It seems like bitbake is not fully parsing my recipe to load my fetcher before it resolves SRCPV. I am not sure what version of BitBake I&apos;m using since I am using Yocto master and bitbake --version reports 1.32.0 which is older than any of the drop down options above.

The fetcher code is here: https://github.com/meta-rust/meta-rust/blob/master/lib/crate.py
The bbclass that is inherited to load that is here: https://github.com/meta-rust/meta-rust/blob/master/classes/crate-fetch.bbclass
The bbclass that is inherited by recipes and in turn inherits the above bbclass is here: https://github.com/meta-rust/meta-rust/blob/master/classes/cargo.bbclass
The recipe that fails is here: https://github.com/cardoe/meta-rust/blob/rustfmt-git/recipes-example/rustfmt/rustfmt_git.bb


The error is as follows:

ERROR: ExpansionError during parsing /var/build/poky/meta-rust/recipes-example/rustfmt/rustfmt_git.bb
Traceback (most recent call last):
  File &quot;/var/build/poky/bitbake/lib/bb/data_smart.py&quot;, line 412, in DataSmart.expandWithRefs(s=&quot;${@bb.parse.BBHandler.vars_from_file(d.getVar(&apos;FILE&apos;, False),d)[1] or &apos;1.0&apos;}.${SRCPV}&quot;, varname=&apos;PV&apos;):
                 try:
    &gt;                s = __expand_var_regexp__.sub(varparse.var_sub, s)
                     try:
  File &quot;/var/build/poky/bitbake/lib/bb/data_smart.py&quot;, line 111, in VariableParse.var_sub(match=&lt;_sre.SRE_Match object; span=(77, 85), match=&apos;${SRCPV}&apos;&gt;):
                 else:
    &gt;                var = self.d.getVarFlag(key, &quot;_content&quot;)
                 self.references.add(key)
  File &quot;/var/build/poky/bitbake/lib/bb/data_smart.py&quot;, line 773, in DataSmart.getVarFlag(var=&apos;SRCPV&apos;, flag=&apos;_content&apos;, expand=True, noweakdefault=False, parsing=False):
                     cachename = var + &quot;[&quot; + flag + &quot;]&quot;
    &gt;            value = self.expand(value, cachename)

  File &quot;/var/build/poky/bitbake/lib/bb/data_smart.py&quot;, line 436, in DataSmart.expand(s=&apos;${@bb.fetch2.get_srcrev(d)}&apos;, varname=&apos;SRCPV&apos;):
         def expand(self, s, varname = None):
    &gt;        return self.expandWithRefs(s, varname).value

  File &quot;/var/build/poky/bitbake/lib/bb/data_smart.py&quot;, line 426, in DataSmart.expandWithRefs(s=&apos;${@bb.fetch2.get_srcrev(d)}&apos;, varname=&apos;SRCPV&apos;):
                 except Exception as exc:
    &gt;                raise ExpansionError(varname, s, exc) from exc

bb.data_smart.ExpansionError: Failure expanding variable SRCPV, expression was ${@bb.fetch2.get_srcrev(d)} which triggered exception NoMethodError: Could not find a fetcher which supports the URL: &apos;crate://crates.io/aho-corasick/0.5.3&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70897</commentid>
    <comment_count>1</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2017-02-23 12:05:32 +0000</bug_when>
    <thetext>I think what you&apos;re trying to do (i.e. implementing custom fetchers in layers) is currently not supported by bitbake. Your fetcher has not yet been added to bb.fetch2 at the time bitbake parses the recipe. So, I think we should turn this bug into an enhancement/feature request for supporting custom fetchers. Another possibility would be for you to just add your custom fetcher directly into bitbake and send it for review on the bitbake-devel mailing list. I don&apos;t know what is the general response (from RP) towards adding new  fetchers, though.

CC&apos;ing RP - he might have some comments/insight.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73077</commentid>
    <comment_count>2</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2017-05-05 10:24:25 +0000</bug_when>
    <thetext>Have you tried using a global inherit (that is, e.g. in local.conf)? That might do the trick.

Setting as needinfo and assigning back to reporter for comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80491</commentid>
    <comment_count>3</comment_count>
    <who name="Hmvp">yoctobugzilla</who>
    <bug_when>2018-05-04 02:55:56 +0000</bug_when>
    <thetext>Adding crate-fetch to INHERIT in local.conf does not solve this issue.

This issue also prevents the devtool from being useful for these recipes regardless of SRCPV parsing</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91877</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-11-02 21:52:33 +0000</bug_when>
    <thetext>The challenge is that the extra module code is added too late in the parsing process for bitbake to see the fetcher module at the time SRCPV is parsed, which is very early in the parsing process.

We&apos;d hoped that INHERIT would solve that but it still isn&apos;t early enough to avoid issues with class being visible for SRCPV. I&apos;m still not sure how to try and address this for external fetcher classes unfortunately.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93430</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-06-09 09:48:07 +0000</bug_when>
    <thetext>Crate support eventually moved into bitbake which resolved this. Before that, our best known method for handling this was in the code removed here:

https://git.yoctoproject.org/poky/commit/?id=2a5dcb0662054c1d6bbe5ffe1c48fee10be30bd0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93431</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-06-09 09:50:15 +0000</bug_when>
    <thetext>If we do ever want to fix this we&apos;d likely need to add some kind of special import mechanism for fetchers. Having the key fetchers in bitbake is probably desirable just to encourage standardisation so this isn&apos;t hugely pressing now crates are fixed and working so moving to a future bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99190</commentid>
    <comment_count>7</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2024-06-13 15:07:57 +0000</bug_when>
    <thetext>The crate code moved to the fetcher which resolved this specific issue. We&apos;re not sure we want the complexity added to the fetcher code to support autorev so for now we don&apos;t plan to do this and the original issue was resolved.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>