{"id":142,"date":"2015-05-30T11:18:34","date_gmt":"2015-05-30T19:18:34","guid":{"rendered":"http:\/\/www.gauntletwizard.net\/wordpress\/?p=142"},"modified":"2015-05-30T11:19:30","modified_gmt":"2015-05-30T19:19:30","slug":"when-is-a-cmake-not-a-cmake","status":"publish","type":"post","link":"https:\/\/www.gauntletwizard.net\/wordpress\/?p=142","title":{"rendered":"When is a cmake not a cmake?"},"content":{"rendered":"<p>I was trying to install some software from source today. After dicking around for a full day last week trying to port it&#8217;s build chain to Bazel, I decided to just install the build toolchain it expects.<\/p>\n<p>I install Cmake, and try to build my program. No dice! This source file requires cmake version 2.8.12, and CentOS 7 comes with 2.8.11. Ergh. So, I go back to source, and grab and make the latest cmake. A quick make, make install, and I go back to the original directory and&#8230; get the same error message?<\/p>\n<pre>\/cmake .\r\nCMake Error at CMakeLists.txt:1 (cmake_minimum_required):\r\n CMake 2.8.12 or higher is required. You are running version 2.8.11\r\n\r\n<\/pre>\n<p>What can this be? Did it not install? I make clean, make install again, and this time I search for where it&#8217;s installing. \/usr\/local\/bin\/cmake ; It seems to work. It&#8217;s in path. I run &#8216;which cmake&#8217; and it tells me &#8221; \/usr\/local\/bin\/cmake&#8221;, as I expect. I run directly from that path, and check the version; 3.2.2, as I expected. What gives? Why does simply running it not give me the expected results? I throw strace at it; The top line of strace shows the correct path:<\/p>\n<pre>execve(\"\/usr\/local\/bin\/cmake\", [\"cmake\"], [\/* 26 vars *\/]) = 0<\/pre>\n<p>At this point, I&#8217;m fairly stumped. Clearly, the old executable still exists, so I search my path for it; The old version of cmake is in \/usr\/bin. I then wonder at what could be causing the redirection, so I launch a new terminal, type cmake &#8211;version&#8230; and I get the correct result! Launching bash as a subshell also gives me what I want. So, what&#8217;s wrong with my initial shell?<\/p>\n<p>At this point, I was fairly stumped, so I asked my dad, an old unix hand, and he pointed me to the &#8216;hash&#8217; builtin. Bash keeps a dictionary of commands to their full pathnames; Presumably for speed, as doing several directory listings for each command would be wasteful, even with all of the PATH directories in ram.<\/p>\n<p>The solution is simply to call &#8216;hash cname&#8217; or &#8216;hash -r&#8217; to cause bash to redo the dictionary entry for cname, or for everything, respectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was trying to install some software from source today. After dicking around for a full day last week trying to port it&#8217;s build chain to Bazel, I decided to just install the build toolchain it expects. I install Cmake, and try to build my program. No dice! This source file requires cmake version 2.8.12, &hellip; <a href=\"https:\/\/www.gauntletwizard.net\/wordpress\/?p=142\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">When is a cmake not a cmake?<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/142"}],"collection":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=142"}],"version-history":[{"count":2,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/142\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/142\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}