<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Boss</title>
    <description>The latest articles on DEV Community by Boss (@ibossptk).</description>
    <link>https://dev.to/ibossptk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F269333%2Ff3a24737-754c-45b5-9c5c-f85c8080d23b.png</url>
      <title>DEV Community: Boss</title>
      <link>https://dev.to/ibossptk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ibossptk"/>
    <language>en</language>
    <item>
      <title>solana-test-validator on m1 without rosetta</title>
      <dc:creator>Boss</dc:creator>
      <pubDate>Tue, 11 Jan 2022 03:22:37 +0000</pubDate>
      <link>https://dev.to/ibossptk/solana-test-validator-on-m1-without-rosetta-9ol</link>
      <guid>https://dev.to/ibossptk/solana-test-validator-on-m1-without-rosetta-9ol</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This approach is tested on v1.9.4&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;solana-test-validator&lt;/code&gt; is very important for local solana program development, but if you have tried to set it up on m1, you know it's not as easy as install and done.&lt;/p&gt;

&lt;h2&gt;
  
  
  The official way
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.solana.com/cli/install-solana-cli-tools"&gt;The official documentation&lt;/a&gt; states that, for MacOS, running this command and you are good to go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-sSfL&lt;/span&gt; https://release.solana.com/v1.9.4/install&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The other command seems to work ok, but...&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;solana-test-validator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You probably get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Version: 1.9.4
Shred Version: 22786
Gossip Address: 127.0.0.1:1024
TPU Address: 127.0.0.1:1027
JSON RPC URL: http://127.0.0.1:8899
⠒ 00:00:01 | Processed Slot: 699 | Confirmed Slot: 668 | Finalized Slot: 668 | Full Snapshot Slot: 600 | Incremental Snapshot Slot: - | Transactions: 1107 | ◎499.997707500
[1]    47143 illegal hardware instruction  solana-test-validator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Prior thesis
&lt;/h2&gt;

&lt;p&gt;All of them suggested that you build from source. Some suggest that you &lt;a href="https://dev.to/nickgarfield/how-to-install-solana-dev-tools-on-an-m1-mac-kfn"&gt;clean up everything including rust and use rosetta&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I personally used a &lt;a href="https://github.com/project-serum/anchor/issues/95#issuecomment-913090162"&gt;non-rosetta approach&lt;/a&gt; on &lt;code&gt;v1.7.x&lt;/code&gt; but it does not work anymore on 1.9.x, since m1 somehow could not build &lt;code&gt;tikv-jemallocator&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;For 1.9.x, we still need to build from source, but what we need to do is similar to &lt;a href="https://github.com/project-serum/anchor/issues/95#issuecomment-913090162"&gt;previous non-rosetta approach&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1) Clone Solana repo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone git@github.com:solana-labs/solana.git
&lt;span class="nv"&gt;$ &lt;/span&gt;git checkout v1.9.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Edit &lt;code&gt;validator/Cargo.toml&lt;/code&gt;, remove or comment out the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="py"&gt;[target.'cfg(not(target_env&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"msvc"&lt;/span&gt;&lt;span class="err"&gt;))&lt;/span&gt;&lt;span class="s"&gt;'.dependencies]&lt;/span&gt;&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="nn"&gt;jemallocator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;package&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"tikv-jemallocator"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="py"&gt;version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0.4.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="py"&gt;features&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;["unprefixed_malloc_on_supported_platforms"]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Then you can build the whole thing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./scripts/cargo-install-all.sh &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;/bin:&lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or optionally, you can just build only &lt;code&gt;solana-test-validator&lt;/code&gt; and use the rest of &lt;code&gt;solana-cli&lt;/code&gt; from prebuilt binaries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cargo build &lt;span class="nt"&gt;--release&lt;/span&gt; &lt;span class="nt"&gt;--bin&lt;/span&gt; solana-test-validator
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;bin
&lt;span class="nv"&gt;$ &lt;/span&gt;./solana-test-validator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Let me know if it works for you or know what exactly &lt;code&gt;tikv-jemallocator&lt;/code&gt; is for (I only know that it's for memory allocation but don't know why it's needed or when it is used).&lt;/p&gt;

&lt;p&gt;Cheers.&lt;/p&gt;

</description>
      <category>solana</category>
      <category>rust</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
